   pointers to structures
  Hi, i have this code:typedef struct ru *ruta;typedef struct ru{char m[3][3];ruta next;}rute;cand some give me a mini example on how to use it?maybe give "m" and next a value and print them...thanks   
  I'm not exactly sure what you are trying to do, but if I follow you correctly I think this should work just fine for you:typedef struct ru *ruta;typedef struct ru{char m[3][3];ruta next;}rute;First, if you are programming in C++, use this format instead:struct rute{ char m[3][3] ruta next;}Otherwise, if you are just trying to code in C, stick with what you have. Also, try to keep your code indented as I did above. You will thank yourself later! :DSotypedef struct ru{ char[3][3]; ruta next;}rute;void main(){ rute* instanceOfRute; instanceOfRute->char[0] = "A"; instanceOfRute->char[1] = "B"; /* ...etc... */ //then just use printf or cout, to display the results as follows: cout << instanceOfRute->[0];}Needless to say, since it appears that you are using a linked list data structure, you will need to make functions to traverse the list.I hope this is helpful to you!:)   ;typedef struct ru *ruta;typedef struct ru{char m[3][3];ruta next;}rute;int main(int argc, char **argv){rute p;strcpy(p.m[0], "1");strcpy(p.m[1], "2");strcpy(p.m[2], "3");p.next = &pprintf("%s", p.next->m[0]);printf("%s", p.next->m[1]);printf("%s", p.next->m[2]);getchar();return 0;};  Typedef is more or less just a #define. It has some extra compiler error checking, but its ultimately just an alias. Officially, this is what the specification says to do:struct foo{  int bar;  struct foo * next;};After then, if you typedef a foo_t, then you can use it interchangably with struct foo.typedef struct foo foo_t;foo_t ball;foo_t powder;ball.next = &powder;  Just have to be careful, because of all the stack variables peppering the replies here.void main(){rute* instanceOfRute;instanceOfRute->char[0] = "A";instanceOfRute->char[1] = "B";/* ...etc... *///then just use printf or cout, to display the results as follows:cout << instanceOfRute->[0];}That would fail horribly considering 'instanceOfRute' has not actually been assigned any value.  Likewise, trying 'instanceOfRute->[0]' seems to be a syntax error because, and somebody correct me if I'm wrong, but neither C or C++ support empty attribute blocks (also known as error C3409)xeddiex has the right idea, but you have to be careful when you get pointers to stack-based objects such as 'p'. In general, you want to stay away from rute p;   // ...SomeInstanceOfP.next = &p;because 'p' will disappear when you exit that scope.By the way... where did this code come from?*cough* source tags *cough*   ;  How do you use source tags? I'm kinda new here buddy. Lend a brother a hand.   ;  *sheepish*:D Oh god! I feel salty...Yes my code is broken but I promise I am not that big of an ass!I do this for a living (see how easy it is :D, you don't even have to know rudimentary programming lol)Sorry about that*/sheepish*   ;Quote:Original post by CplusplusDEMIGODHow do you use source tags? I'm kinda new here buddy. Lend a brother a hand.click "edit" on my post to see how i do this :);  Cool, thanks for not flaming me. You rock. ++points;   