Page 1 of 1

structs error

Posted: Fri Oct 18, 2002 11:41 am
by Tom
Hello, I have a prob.

I can't use structs. That's it.

I type in perfectly good ones, and I get compiler errors.

That's it.
Thank you,

Re:structs error

Posted: Fri Oct 18, 2002 12:06 pm
by dronkit
In C? with which compiler? show us some code! ;)

Re:structs error

Posted: Fri Oct 18, 2002 12:37 pm
by Whatever5k

Code: Select all

struct foo
{
   int bla;
   int blo;
}; /* don't forget the ; */

int main(void)
{
  struct foo my_foo;

  my_foo.bla = 1;
  my_foo.blo = 2;

  printf("my_foo.bla = %i\n", my_foo.bla);
  printf("my_foo.blo = %i\n", my_foo.blo);

  return 0;
}
This will definitely work...I really can see no trouble with that - maybe you forget the ';' at the end of the structure?

Re:structs error

Posted: Fri Oct 18, 2002 1:14 pm
by .bdjames
typedef struct{
..
} struct_name;

struct_name a_struct;

Re:structs error

Posted: Fri Oct 18, 2002 5:44 pm
by _tom
still didn't work... as I said, I typed in perfectly good code with gcc ...someverison I think 2.96 ( I think )

Re:structs error

Posted: Sat Oct 19, 2002 9:35 am
by Schol-R-LEA
Could show us the code in question, and the error messages that it gives? It would help a lot in putting the problem in context.

Re:structs error

Posted: Sat Oct 19, 2002 8:42 pm
by Tom
the strangest computer thing that ever happend, suddely it works! and linux is suppose to be stable!!!

Re:structs error

Posted: Sun Oct 20, 2002 8:31 am
by dronkit
linux is pretty stable. Anyway it doesn't have anything to do with linux but with gcc and/or whatever you're using to compile... I've never heard anything like this before.. which gcc are you using? was your file typed in dos or linux? did you change anything?

Re:structs error

Posted: Sun Oct 20, 2002 9:41 am
by Whatever5k
I bet (and am pretty sure) that it was your fault... . It's actually impossible that something doesn't work the first time, and the next time, it does - the only reason is a time conflict, but don't think that's a problem...
It was your fault ;)

Re:structs error

Posted: Sun Oct 20, 2002 9:51 am
by dronkit
"A novice was trying to fix a broken Lisp machine by turning the power
off and on. Knight, seeing what the student was doing spoke sternly:
'You can not fix a machine by just power-cycling it with no understanding of
what is going wrong'.

Knight turned the machine off and on. The machine worked."

Just a thought from "fortune" that i wanted to share here ;)