#include<stdio.h>
int D21_1_prntval(void) {
int bph2o = 212;
int rv;
rv = printf("%d F is water‘s boiling point.\n", bph2o);
printf("The printf() function printed %d characters.\n", rv);
return 0;
}
#include<stdio.h>
int D21_2_longstrg(void) {
printf("Here‘s one way to print a ");
printf("long string.\n");
printf("Here‘s another way to print a long string.\n");
printf("Here‘s the newest way to print a "
"long string.\n");
return 0;
}
#include<stdio.h>
#pragma warning(disable:4996)
int D21_3_input(void) {
int age; //变量
float assets; //变量
char pet[30]; //字符数组,用于储存字符串
printf("Enter your age,assets, and favourite pet.\n");
scanf("%d %f", &age, &assets);//这里要使用&
scanf("%s", pet);//字符数组不使用&
printf("%d $%.2f %s\n", age, assets, pet);
return 0;
}
转换说明 | 含义 |
---|---|
%c | 字符 |
%d | 有符号的十进制整数 |
%e,%f,%g,%a | 浮点数(C99新增%a) |
%E,%F,%G,%A | 浮点数(C99新增%A) |
%i | 有符号的十进制整数 |
%o | 有符号的八进制整数 |
%p | 指针(地址) |
%s | 字符串,从第一个非空白的字符开始,到下一个空白字符之间的所有字符都是输入 |
%u | 无符号的十进制整数 |
%u,%X | 有符号的十六进制整数 |
C连载21-printf带返回值,打印长字符串以及scanf
原文:https://www.cnblogs.com/ruigege0000/p/13593850.html