#include <stdio.h>
struct point
{
int x, y;
};
int main(int argc, const char * argv[])
{
struct point someArray[3] = { {0,1}, {2,3}, {0,0} };
printf("%d %d", someArray[0].x, someArray[0].y);
return 0;
}
with no errors or warnings.
i'm getting errors using gcc.
in Xcode, it compiles and runs fine.
the errors i get using gcc:
1:error: expected '=', ' ,', ':', 'asm' or '_attribute_' before '<' token
: In function "main':
12: error: array type has incomplete element type
14: warning: implicit declaration of function 'printf'
12: warning: unused variable 'someArray'
sorry i did not include the error messages and warnings initially
There is no '<' token in function main().
The #include <stdio.h> directive should have inserted a declaration of
printf() into your program, so an implicit one should neither have been
needed nor generated.
someArray is not unused.
Conclusion: something is radically wrong. At a minimum, you should give
us the actual command line you used to compile the code. Secondly, check
to make sure that the code you've given us is EXACTLY the code that is
present in your program. If you copied it by hand the first time - DON'T
do that - cut and paste the full text of your program directly into your
next message without making any modifications. If you gave us a
simplified version of the actual program, check to see whether the
simplified version demonstrates the same problem - if it doesn't, then
make it less simplified, until you can show us a program that does
demonstrate the problem.
Make sure that the code you show us and the compilation command that you
show us are exactly the code and exactly the command that was used when
you got the error messages that you've shown us.
One possibility is that your code contains some non-printing characters
that are causing it to appear very differently to your compiler than it
does in your message. If you're using a unix-like system, try the "od
-c" command on your file, and show us the results.