+ 1
I don't understand the meaning of this sentence.
Format specifiers begin with a percent sign % and are replaced by corresponding arguments after the format string.
4 odpowiedzi
+ 3
哪一課的?這一課嗎?
https://www.sololearn.com/learn/C/2912/
%d 整數
%f 小數
%c char
例如:
printf("%d \n", c);
format string 指 "%d \n"
argument 指 variable c
printf("%f \n", salary);
format string 指 "%f \n"
argument 指 variable salary
在第二課,第二個 code右下方,按那個 TRY IT YOURSELF,進入 code playground, 然後Run,看output。
- - -
Due to Sololearn Q&A forum rules, please use meaningful question name and relevant tags. For this question, the tag should be "c" and "format-specifier". The question shoud be "Format Specifier in C". Please correct your question, thanks.
+ 3
i.e
int num1 = 1;
int num2 = 2;
printf("%d and %d", num1, num2) ;
%d is a format specifier for integers.
in the above example
first %d will be replaced by num1
second %d will be replaced by num2
output : 1 and 2
if you switch the places of num1 and num2
like :
printf("%d and %d", num2, num1) ;
output : 2 and 1
there are many format specifiers it's what specifies how a value is treated, as a char or int or float...
0
%d,%s,%f like that are position holder's