I have a struct that looks like the following:
typedef struct
{
char matrikelnr[10];
double note;
} Hashtable_Entry_t;
And then I try to fill the struct in the main:
#include <stdio.h>
#include <string.h>
int main(int argc, char const *argv[])
{
Hashtable_Entry_t* student;
strcpy(student->matrikelnr, "70468878");
student->note = 1.0;
printf("%s, %.1f \n", student->matrikelnr, student->note);
Hashtable_Entry_t* student2;
printf("Before 2nd strcpy.\n");
strcpy(student2->matrikelnr, "70468878");
printf("Before 2nd strcpy.\n");
student2->note = 1.0;
printf("%s, %.f", student2->matrikelnr, student2->note);
return 0;
}
And when I then take a look at the output I see that the printf() after the second strcpy() wont run and the code just stops:
70468878, 1.0
Before 2nd strcpy.
So can someone tell me what is it that I'm doing wrong?