- 1

Help with the error?

So I have a homework assignment to make a code that has a Student struct/class and does some things with it Hence if the input is 11, it will take a Student and add it to the array But it get an error there, after looking online I couldn't find any results https://code.sololearn.com/cjHol0VT1gTx/?ref=app This is my python attempt on making it and it works : https://code.sololearn.com/cP1dkMPKafBP/?ref=app

29th Nov 2021, 1:51 PM
Sadra Shakouri
Sadra Shakouri - avatar
3 odpowiedzi
+ 2
The problem seems to come from this line : "Student arr[ ] ={0}". It is the way to initialize an array of integers for example, but here you have an array of a structure called student. So you could either make an array of Student of a certain size to use it : "Student arr[5]" for an array of 5 students for example. Or you could initialize it like you did, but since it is a structure with multiple members you have to initialise all of them : "Student arr[]= {"name","surname","id",1,"whatever"}; " for example.
29th Nov 2021, 5:00 PM
fire ball
fire ball - avatar
0
fire ball thanks, but it says its from the switch. I'll try it tho My laptop broke so im getting final results and not compile time results so i cant find the cause
29th Nov 2021, 5:40 PM
Sadra Shakouri
Sadra Shakouri - avatar
0
fire ball holy s*** it worked Thanks alot m8
29th Nov 2021, 5:45 PM
Sadra Shakouri
Sadra Shakouri - avatar