+ 1

Plz help me🥺

I'm getting segmentation fault when testing this code. I tried so hard but can't find the error. The segmentation fault occurs when running. Plz help me https://code.sololearn.com/cCpr1H3LVPOJ/?ref=app

21st Nov 2021, 4:23 PM
Rishi
Rishi - avatar
3 Answers
+ 2
At first glance 'cse' 'mech' and 'eee' Record pointers are not initialized (they do not default to NULL), and the 'add' function tries to read them
21st Nov 2021, 7:15 PM
Angelo
Angelo - avatar
+ 1
hmm, your code doesn't give me a segmentation fault, the output says that it didn't the department and then finds that department and asks a bunch of appropriate input and then uhh... it does nothing. here was my input: 1 cse rellot 45 35 357587 2 1 cse rishi 21 45 357586 2
21st Nov 2021, 4:58 PM
Rellot's screwdriver
Rellot's screwdriver - avatar
+ 1
Rellot's screwdriver yeah it just gets the input and stores it. It gave me segmentation fault because of the reason that I didn't initialize the pointers to NULL and tried to access the random memory segment they were pointing to, that resulted in error. Thank you for helping Angelo and @Rellot's screwdriver
22nd Nov 2021, 5:31 AM
Rishi
Rishi - avatar