06-14-2007 01:05 PM
06-14-2007 01:15 PM - edited 06-14-2007 01:15 PM
Move the declaration for b under the declaration for a. C does not allow you declare variables in the middle of your code segment like you can in C++.
int main(int argc, char *argv[])
{
Point2D a;
Point2D b;
a.x = 1;
a.y = 0;
display(a);
b.x = 2;
...
should work
Message Edited by mvr on 06-14-2007 01:18 PM
06-14-2007 01:17 PM
06-14-2007 01:25 PM - edited 06-14-2007 01:25 PM
For what it is worth you can define a variable in a local code block that has a scope only within that block.
Int func(void)
{
int a;
a=0;
printf("a=%d\r\n", a);
{ // local block
int b;
b=20;
printf("b=%d\r\n", b);
}
return a;
}
Can be useful when doing things in a more C++ like style.
OT: I have no idea what causes the double spacing of lines in reply messages.
Message Edited by mvr on 06-14-2007 01:26 PM
06-14-2007 01:31 PM