could somebody tell me the proper form to create a linked list? I thought the
[c]
typedef struct myStruct {
int data;
myStruct *next;
};
[/c]
was the way, but the OJ demonstrated me that I was wrong :(
linked lists
Moderator: Board moderators
-
- New poster
- Posts: 14
- Joined: Tue Nov 12, 2002 6:04 pm
- Location: Bulgaria
I received compile error... however, I did a bit of search on the net, and I found one way the OJ compiles it:
[c]
typedef struct _myStruct {
int data;
struct _myStruct *next;
}myStruct;
[/c]
this compiles both on my machine and the OJ's - though to be honest, I pretty much don't know why I had to put the underscore :( could someone give me a link to a good & clear explaination of this issue? now I just have to figure out why I am getting WA, but that's another forum...
[c]
typedef struct _myStruct {
int data;
struct _myStruct *next;
}myStruct;
[/c]
this compiles both on my machine and the OJ's - though to be honest, I pretty much don't know why I had to put the underscore :( could someone give me a link to a good & clear explaination of this issue? now I just have to figure out why I am getting WA, but that's another forum...
-
- New poster
- Posts: 14
- Joined: Tue Nov 12, 2002 6:04 pm
- Location: Bulgaria
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
Code: Select all
typedef struct _x
{
struct _x *next;
} X;
in C++ we could write
Code: Select all
struct X
{
X *next;
};


Regards
Dominik Michniewski