+ 1
What is the meaning of %s in c?
4 Respostas
+ 4
It's a format specifier that is used for strings.
+ 1
And also you can use it for characters in place of '%c'...
+ 1
Arin Bagul
%s tells printf that the corresponding argument is to be treated as a string (in C terms, a 0-terminated sequence of char ); the type of the corresponding argument must be char * . %d tells printf that the corresponding argument is to be treated as an integer value; the type of the corresponding argument must be int
https://stackoverflow.com/questions/9026980/what-does-s-and-d-mean-in-printf-in-the-c-language#:~:text=%25s%20tells%20printf%20that%20the,corresponding%20argument%20must%20be%20int%20.
0
It is not just instead of printf("hello") that you should do this printf("%s", "hello"); but you want to combine stuff like this:
(Assuming you know %d)
Printf("%d %s", 2, "people") prints this:
2 people