Blanks vs: Nulls

I'm relatively new to Pro*C programming. In the following example:

char name[21]; EXEC SQL SELECT 'John Doe' INTO :name FROM DUAL;

"John Doe" is in positions 0-7, blanks in 8-19, and a null in 20. I would really prefer the null to be in position 8 and I don't care what's after that. I wrote a trim function to do that. If I forget to trim and insert the data into an Oracle table, it creates problems.

Is there a better technique?

Yes. But it is more involved.

/* you need a function dberror(int errcode, int line) that displays errors and exits */
void dberror(int errcode, int line)
{
       fprintf(stderr,"Error %d on line %d\n", errcode * -1, line);
       EXEC SQL
          ROLLBACK WORK RELEASE;
       exit(1);      
      
}
#define  ORACHK { if ( sqlca.sqlcode < 0) dberror(sqlca.sqlcode, __LINE__); }
typedef char CHAR21[21];
EXEC SQL BEGIN DECLARE SECTION;
     EXEC SQL TYPE CHAR21 IS STRING(21);
     CHAR21 name="";
     short ind=0;
EXEC SQL END DECLARE SECTION;

EXEC SQL
     SELECT 'Tom Jones' 
     INTO :name :ind
     FROM dual;
     ORACHK;

I added the ORACHK because you absolutely need to check return codes in Oracle.
What you do is up to you. This one is not friendly it just exits. You realize this won't compile; it is several different things blobbed together.