+ 2
Another C question by the newb
If I want to accept a number from a user to determine how many strings I will then accept for example: 3 Bob A Mike B Charlie C How can I do that allowing the number to be variable and define the rest of the input?
5 odpowiedzi
+ 1
I am also a C newb :)
And I tried to implement this now on my own, by the time I finished you already had the answer :)
I used a 2d char array though..
Coder Kitten I assume you proposed a struct to store the firstname and the letter separately, as in the example "Bob A"?
https://code.sololearn.com/cf23Ci3gNpHm/?ref=app
+ 1
Ok with your help put this together and it worked!
https://code.sololearn.com/cdFmjWcGoXhG
0
thanks for your help i was making the mistake of using %s\n only and thinking it would grab the name and initial!
0
i prefer fgets too. could i iterate through fgets for n number of times? would that even work?
0
i like it! thanks a million