Friday 15 March 2013

compiler error: "Expected ;" error in C struct -


I am trying to add a struct to my program using this syntax: < / P>

  struct foo {char bar [] = "falcon"; Four quacks [] = "ABC"; / * And similarly;   

For some reason, I get an error on each variable declaration within struct , saying that I have to add a semicolon, and a loop with it . Suggestion syntax will be something like this

  struct foo {char bar []; =; ; ; ;;;;;;;;;;;;;;;;;;;;;; * * Infinite semicolon * / "falcon"; }   

This is the first time I have encountered such error; Am I really doing something wrong, or is it an issue with the compiler?

This is nothing to do with Xcode exactly

You are getting the compiler error because you can not initialize the strokes in this way.

The definition of structure type is only about type, at this point it is not possible to assign members to values. Maybe you mean

  struct foo {char * bar; Four * falcon; }; Struct foo x = {"quirk", "foobar"};   

Instead?

No comments:

Post a Comment