for some reason, when I try to compile my code the .exe file just disappears after its done... without any errors or warnings.
This is what my code looks like:
#include <stdio.h>
#include <stdlib.h>
typedef struct student_
{
int matnum;
char vorname[20];
struct student_ *next;
} student;
int main (int argc, char **argv)
{
student hans;
hans.matnum = 12;
student peter;
peter.matnum = 13;
peter.next = NULL; // THIS PART CAUSES MY PROBLEM
hans.next = &peter;
student *curr = &hans;
while(curr != NULL)
{
printf("matnum: %d\n", (*curr).matnum);
curr = curr->next;
}
return 0;
}
What I want it to do is iterate through curr and set it to the next everytime curr wasn't NULL already. So if next is NULL, than the while-loop should stop.
peter.next = NULL; // THIS PART CAUSES MY PROBLEM
This is how I want to achieve that but it doesn't work. :\
From the comments:
I don't get an error. AFter I type in "gcc -Wall -o test test.c" the test.exe is there for a second and then it gets deleted.