| View previous topic :: View next topic |
| Author |
Message |
psiko_scweek
Joined: 12 Nov 2005 Posts: 42
|
Posted: Wed May 24, 2006 1:14 am Post subject: Help!, Whats wrong with my code? |
|
|
| Code: |
typedef struct{
int x, y;
}Objects;
Objects Robot[10];
Robot[1].x = 100; |
Ive been trying to figure this out for about 2 days, ive looked on the net and it seems to be legit code, but i keep getting the error
| Code: |
main.c:58: error: syntax error before '.' token
make: *** [main.o] Error 1 |
and i dont understand why. |
|
| Back to top |
|
 |
fish
Joined: 08 Feb 2006 Posts: 25
|
Posted: Wed May 24, 2006 2:33 am Post subject: |
|
|
| The assignment is outside of the main() function. |
|
| Back to top |
|
 |
psiko_scweek
Joined: 12 Nov 2005 Posts: 42
|
Posted: Wed May 24, 2006 3:42 am Post subject: gotta be kidding me. |
|
|
thats all my problem is?
thanks! ill try that when i get home from work. |
|
| Back to top |
|
 |
CyberBill
Joined: 26 Jul 2005 Posts: 86 Location: Redmond, WA
|
Posted: Wed May 24, 2006 7:20 am Post subject: |
|
|
You're code should look more like:
| Code: |
typedef struct{
int x, y;
}Objects;
Objects Robot[10];
int main()
{
Robot[0].x = 100;
Robot[0].y = 100;
}
|
Remember that an array of size 10 is indexed 0 - 9, not 1 - 10. |
|
| Back to top |
|
 |
|