gets與scanf 功能都是讀入字元,
但scanf不吃空白, 即如果輸入 "Lam with c",
scanf只會讀入"Lam" ,
但scanf不吃空白, 即如果輸入 "Lam with c",
scanf只會讀入"Lam" ,
遇到空白後的字一概不理;
相反地 , gets 可以讀入埋空白後面的字.
相反地 , gets 可以讀入埋空白後面的字.
-----------------------------------------------
#include <stdio.h>int main(void){ char s[20]; printf("請輸入連續的字元....\n"); gets(s); printf("剛剛輸入的字串: %s\n", s); return 0;}
沒有留言:
張貼留言