Re: nested structures and initialization



On Wed, 31 Oct 2007 13:11:09 -0000, Sheldon <shejo284@xxxxxxxxx>
wrote:
<much snippage>

retv->operationalfile = NULL;
retv->tunedfile = NULL;
retv->radarfile = NULL;
<more snippage>

c: In function `NewSatellite':
c:73: error: incompatible types in assignment
c:74: error: incompatible types in assignment
c:75: error: incompatible types in assignment
c:76: warning: statement with no effect

I told you in the email I sent you that your initialisation of these
strings was nonsense. You are trying to assign the value NULL to a
variable of type array-of-char. You need to set the first character
of the array-of-char to the value '\0', thus:

retv->operationalfile[0] = '\0';

Alternatively, initialise the entire string to zeros (overkill):

memset(retv->operationalfile, 0, sizeof retv->operationalfile);

What I am missing here?

Clues?
--
PGP key ID 0xEB7180EC
.



Relevant Pages

  • Re: incompatible types in assignment
    ... int main ... test3.c:7: incompatible types in assignment ... You can't assign to arrays in C. ...
    (comp.lang.c)
  • Re: initializing struct
    ... Carramba wrote: ... Joachim Schmitz skrev: ... This doesn't work: "incompatible types in assignment" ...
    (comp.lang.c)
  • glib-wv
    ... making all in glib-wv ... gstrfuncs.c:117: error: incompatible types in assignment ... OS: RHEL5 64bit ...
    (RedHat)
  • Re: Linked list w/ structure
    ... I assume you meant after compiling. ... a.c:59: error: incompatible types in assignment ...
    (comp.lang.c)