常量 | 類型 | 轉換說明(%轉換符號) |
---|---|---|
12 | int | %d |
0X3 | unsigned int | %#x |
'C' | char(其實是int) | %c |
2.34E07 | double | %e |
'\040' | char(實際上int) | %c |
7.0 | double | %f |
6L | long | %ld |
6.0f | float | %f |
0x5.b6p12 | float | %a |
012 | unsigned int(八進制) | %#o |
2.9e05L | float | %Le |
's' | char | %c |
100000 | long | %ld |
'\n' | char(其實是int | %c |
20.0f | float | %f |
0x44 | unsigned int(十六進制) | %x |
-40 | int | %d |
char ch = '\r'; char ch = 13; char ch = '\015'; char ch = '\xd';
#include<stdio.h> #include<string.h> //提供strlen()函數的原型 #pragma warning(disable:4996) #define DENSITY 62.4 //人體密度(單位:磅/立方英尺) int D15_talkback() { float weight, volumn; int size, letters; char name[40]; //name是一個能夠容納40個字符的數組 printf("Hi!What's your first name?\n"); scanf("%s", name); printf("%s ,what's your weight in pounds?\n", name); scanf("%f", &weight); size = sizeof name; letters = strlen(name); volumn = weight / DENSITY; printf("Well ,%s ,your volumn is %2.2f cublic feet.\n", name, volumn); printf("Also,yout first name has %d letters,\n", letters); printf("and we have %d bytes to store it.\n", size); return 0; }
顯示結果: git