scanf | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

scanf

I wrote two words to char array with scanf but it took only one word. Can you explain?

9th Jan 2019, 10:17 PM
Zeynep Hande Coşkun
Zeynep Hande Coşkun - avatar
1 Answer
+ 3
Scanf will read until the first white-space character. You can try gets, even better- fgets instead. https://stackoverflow.com/questions/34007197/scanf-behaviour-for-strings-with-more-than-one-word Remember to read the official documents. ✌️
9th Jan 2019, 11:34 PM
dρlυѕρlυѕ
dρlυѕρlυѕ - avatar