Process finished with exit code 11 (C)
Answered
Hello, I have an issue were, after proving input for char ID[9] (any number), the program exits and writes in the console: "Process finished with exit code 11".
I have no idea what went wrong, I am pretty sure my code is fine.
void addStudentWithCredentials(struct StNode* head) {
char fullName[60], ID[9];
printf("Enter full name: ");
fgets(fullName, 40, stdin);
printf("Enter ID: ");
scanf("%s", ID);
struct Student* tempSt = malloc(sizeof(struct Student));
struct StNode* newNode = calloc(1, sizeof(struct StNode));
if(tempSt != NULL) {
strcpy(tempSt->fullName, fullName);
strcpy(tempSt->ID, ID);
strcpy(tempSt->stCode, '00000');
Please sign in to leave a comment.
You've put single quotes instead of double in your last line, so you're effectively dereferencing a null pointer in it ('0000' equals to 0). You should get an exception if you debug the program, also CLion should give you a yellow warning on this line.
Thank you Anna!