+ 1
Help with this C code.
I have this code: char name[50]; fgets(name, 50, stdin); printf("your name %s is ugly", name); input: Frank output: your name Frank is ugly. why the output has a new line? how can I avoid the new line? I want to print the name in the same line, but I don't know how when I use fgets.
5 Réponses
+ 1
Tind Yes you have right... Im keep to old standards... I have to update myself 😀
0
Because fgets INCLUDE the newline in your string (if present)
http://www.cplusplus.com/reference/cstdio/fgets/
You can use scanf or gets for that
0
Tind I see, but by doing that I can eliminate the new line? how can I do that? I'm learning C and I don't know how to implement it