+ 2

Want to save and access the input function in C

I want to know how can i save the scanf data in C program and user it further in the same program

6th Feb 2018, 3:44 AM
jagdish kumar sahu
jagdish kumar sahu - avatar
5 Respuestas
+ 3
Perhaps you may check: https://www.sololearn.com/learn/1353/?ref=app And also check out : https://www.sololearn.com/learn/3023/?ref=app The format specifiers in the above lesson work just in the same way for scanf, just that it requires a reference instead of the normal variable.
6th Feb 2018, 3:52 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 2
i want to input the student name of 4 students and then get output of any one student name by inputing the student number
6th Feb 2018, 4:16 AM
jagdish kumar sahu
jagdish kumar sahu - avatar
+ 2
If you want to get the student names then prompt the user once again to enter the student number, that would be impossible in Sololearn because of the fact that there is no live console. What you could do instead is set a fifth input variable, this one as a number, and set it in a switch statement to test its value (here's a lesson on switch, if you need-https://www.sololearn.com/learn/3018/?ref=app).
6th Feb 2018, 4:45 AM
Faisal
Faisal - avatar
+ 1
What you could do is set multiple different variables, all of them being an array of chars, and set the scanf function to scan for multiple different inputs, all being stored to a corresponding variable. For example, if you wanted to scan for the name is 4 different students: char s1[100]; char s2[100]; char s3[100]; char s4[100]; scanf("%s %s %s %s", &s1, &s2, &s3, &s4); printf("%s %s %s %s", s1, s2, s3, s4);
6th Feb 2018, 4:27 AM
Faisal
Faisal - avatar
+ 1
after I scanned 4 names.... I want a program which will display the name by typing the name number i mean If i will type 3 it should tell me the number which i typed earlier in the 3rd number
6th Feb 2018, 4:39 AM
jagdish kumar sahu
jagdish kumar sahu - avatar