+ 1
I'm confuse with this \n
Which makes new new line in code but why it's after the name we use \n instead of after age as it's logic more or any other alternative ways do it ?? https://sololearn.com/compiler-playground/czdXkyI0Fe1q/?ref=app
3 Antworten
+ 1
That is because the new line is used inside a string. We don't do it after an integer simply because you cant.
For outputting a string, you can put the new line either inside the "Name:%s\n" or after the name "Henry\n".
For other values, like integer, double . . . we put the new line inside the format specifier string. printf("Age:%d\n", 10);
0
Linux in line 5 I put \n after the age: %d then it must be suppose to be print next line but not? Why
0
I suppose you meant this from your code: "printf("Age:%d\n", 42);"
It does work, I'm not sure what you mean by its not printing a new line, but the output is "Age:42" and a new line.
If you put the new line between "Age:" and the format specifier: "printf("Age:\n%d", 42);" then that will print:
Age:
42
Could you please clarify what output its giving you? Or what you really want to output?