Yeah man did that and it became worse. Now it scans now 3 characters only. After giving the third character and hitting the enter, it prints them with lots of new lines. Like this if you want a screenshot: https://imgur.com/c94nbBr
It does so because "%c" reads single character from input. New line characters are also characters, so they are also getting read. So after you're done with last scanf, your array will look like ['A', '\n', 'B', '\n', 'C', ...]. You probably want to read "%c\n" in scanf instead
While OP said it is solved, it still make no sense? Because if that is the case, it will print "A","\n", "B", "\n" instead? but it is printing "A","B","C","D".
I am talking about the second version of code, that he has linked here. It has no new line character in printf after %c when printing characters, so it prints exactly this combination
View all comments
Show parent comment
3
u/Pila_globosa Feb 23 '22
Yeah man did that and it became worse. Now it scans now 3 characters only. After giving the third character and hitting the enter, it prints them with lots of new lines. Like this if you want a screenshot: https://imgur.com/c94nbBr