C 中 scanf 和 printf 函數用於從標準輸入讀取資料和向標準輸出寫入資料。 scanf 用法:int scanf(format, ...),其中format 為要讀取的資料格式,... 為要讀取的變數位址;printf 用法:int printf(format, ...),其中format 為要寫入的資料格式,... 為要寫入的變數。
C 中scanf 和printf 用法
scanf 和printf 是C 中兩個常用的標準輸入/輸出函數。它們用於分別從標準輸入讀取資料和向標準輸出寫入資料。
scanf
#用法:
#int scanf(const char *format, ...);
其中:
:指定要讀取的資料的格式字串。
:要讀取的變數的位址。
格式說明詞:
int age;
char name[50];
scanf("%d %s", &age, name);
用法:
int printf(const char *format, ...);
int age = 25; printf("姓名:%s,年龄:%d\n", name, age);
以上是c++中scanf和printf用法的詳細內容。更多資訊請關注PHP中文網其他相關文章!