Hi all, what is the syntax error below? int myarray[2] = {10,20}; while it compiles ok if int is changed to char. Regards Dravid
"You have most likely made some sort of trivial mistake in the code preceding that line" Or, you have not posted here exactly what you had in your source file. Use cut-and-paste to avoid this possibility. Perhaps you could also post a few lines of context, and the full verbatim text of the entire error message?
or you have not defined the "int" type
"or you have not defined the 'int' type" Err... int is a standard 'C' type; in fact, it is the standard 'C' data type!
Or have #defined "int" (in which case you deserve what you get...) Context counts, too. Consider: long int myarray[2] = {10,20}; which will fail to compile if you change "int" to "char".
"Context counts, too." Very true - especially if there are other errors earlier in the file! Faulty macro expansions are also a very good way to mess-up the context - which is why I keep recommending that people read the preprocessor listing.
The error goes away if the initialisation is done in next statements. int myarray[2]; myarray[0]=10; myarray[1]=20;