+ 1

How to input a string using scanf() in C ?

How to input a string of n characters using scanf()?

4th Apr 2019, 3:01 AM
Krishna Kumar
Krishna Kumar - avatar
2 odpowiedzi
4th Apr 2019, 3:24 AM
Sachin Artani
Sachin Artani - avatar
+ 1
1- Declare your string variable. 2- In scanf(), use %s as your format specifier. 3- When assigning the format specifier to a variable, don't use '&' (according to my experience, adding & never worked.) Example: char str[10]; scanf("%s",str); Hope this helps :)
5th Apr 2019, 6:56 PM
Purohit Iyer
Purohit Iyer - avatar