structs error

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Tom

structs error

Post 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,
dronkit

Re:structs error

Post by dronkit »

In C? with which compiler? show us some code! ;)
Whatever5k

Re:structs error

Post 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?
.bdjames

Re:structs error

Post by .bdjames »

typedef struct{
..
} struct_name;

struct_name a_struct;
_tom

Re:structs error

Post by _tom »

still didn't work... as I said, I typed in perfectly good code with gcc ...someverison I think 2.96 ( I think )
Schol-R-LEA

Re:structs error

Post 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.
Tom

Re:structs error

Post by Tom »

the strangest computer thing that ever happend, suddely it works! and linux is suppose to be stable!!!
dronkit

Re:structs error

Post 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?
Whatever5k

Re:structs error

Post 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 ;)
dronkit

Re:structs error

Post 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 ;)
Post Reply