#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct STU{//Structure for transaction to make linked list
unsigned int SID;
unsigned int enteringgrade;
unsigned int year;
char University[32];
char Student[32];
struct STU *next;
}Node;
Node* addrecord(unsigned int, unsigned int, unsigned int, char*, char*, Node*);
void printrecord(Node *);
int main() {
char str[4];
Node *start = NULL;
struct STU stu;
while(strcmp(str, "END") != 0)
{
scanf("%s", str);
if (strcmp(str, "Student") == 0) {
scanf("%u %u %u %s %s", &stu.SID, &stu.enteringgrade, &stu.year, &stu.University, &stu.Student);
start = addrecord(stu.SID, stu.enteringgrade, stu.year, stu.University, stu.Student, start);
}
else if (strcmp(str, "print") == 0)
{
printf("Linked List Values: \n ");
printrecord(start);
}
}
free(start);
return 0;
}
Node * addrecord(unsigned int SID, unsigned int grade, unsigned int year, char* uni, char* Student2, Node *start) {
Node *newnode;
int i = 0, k = 0;
newnode = (Node *) malloc(sizeof(Node));
newnode-> SID = SID;
newnode-> enteringgrade = grade;
newnode-> year = year;
for(i = 0; uni[i] != '\0'; i++)
{
newnode -> University[i] = uni[i];
}
for(k = 0; Student2[k] != '\0'; k++)
{
newnode -> Student[k] = Student2[k];
}
newnode->next= start;
start = newnode;
return start;
}
void printrecord(Node *start) {
Node *current = start;
while ( current != NULL) {
printf("%u %u %u %s %s", current->SID, current-> enteringgrade, current-> year, current-> University, current->Student);
current = current ->next;
}
}
Input 1st IDE DevC++
Student 10 99 2022 Stanford Charlie Smith print
Output 1st IDE DevC++
Linked List Values:
10 99 2022 Stanford CharlieOGONSERVER=\DESKTOP-1KFBc
Input 2nd IDE - Clion
Student 10 99 2022 Stanford Charlie Smith
Output 2nd IDE - Clion
Linked List Values:
0 4096 0 ε ε
Process finished with exit code -1073741819 (0xC0000005)
Here is my confusion. I am trying to create a code that allows the user to input a student with the fields ID, Grade, Year, University(character array) and Student(character array). My main IDE is Clion while devC++ is another I had initally, but it has less functions. I understand the jargon being output in my first IDE as it is memory allocated by the string, but not used. I cannot understand why my second IDE won't output anything at all. Any hints or thoughts would be helpful. My only thoughts is that it is a memory issue and DevC++ will use different memory? Thanks!