0
C
Escape sequences begin with a backslash \: \n new line \t horizontal tab \\ backslash \b backspace \' single quote \" double quote Format specifiers begin with a percent sign % and are replaced by corresponding arguments after the format string. A format specifier can include several options along with a conversion character: Help to understand
4 Respuestas
+ 4
The role of the % sign in fornat specifiers is similar to that of \ in escape sequences.
You need to tell to the compiler that you are going to print a float. How can you do that? Whatever you write in printf is going to be printed.
The solution is to use %. Every time you use % the compiler is going to look for the following characters to put them together getting a special meaning.
ps: if you just need to print a %, do %% not \%
+ 3
If you want to print:
CIAO
you do:
printf("CIAO");
If you want to print:
"CIAO"
and try to do that:
printf(""CIAO"");
you will get an error because the two double quotes before CIAO open and close a string to print. The same is for those after CIAO. So CIAO have no quotes.
How can you tell to the compiler that you just want to print double quotes?
The solution is to use the backslash.
Eerytime you use the backslash in a code, the compiler is going to look for the next character and put them together to create an escape sequence.
Doing \" tells to the compiler that the double quote is not to be used to open or close a string, but just as a character part of the string.
Here's the proper printf:
printf("\"CIAO\"");
+ 1
this is fromc i didn’t understand First Complete your c course