+ 1
how to use scanf to input charecters "hello world"
4 Réponses
+ 2
badal jha it should be like
scanf("%[^\n]s", char)
It will keep taking input until it doesn't encounter any new line[Enter key].
+ 1
what if i use scanf("%[^\n]",char) is it works?
+ 1
you can use this code to input and print any character string or character array using scanf()
But as Avinash said gets() is better and easy.
https://code.sololearn.com/cfK3B8W8y3fX/?ref=app
- 1
You cannot use scanf to take a string type as long as it is more than 1 word.
May be you can use gets().
Edit: Sorry wasn't aware of the solution others mentioned.