當前位置

首頁 > 商務英語 > 計算機英語 > c語言gets的用法

c語言gets的用法

推薦人: 來源: 閱讀: 2.5W 次

C語言中緩衝區就是內存中開闢的一塊存儲空間。數組也是一個緩衝區。或者你用內存操作函數自己去開闢一塊內存空間也是緩衝區。下面我們來看看c語言gets的用法。

padding-bottom: 100%;">c語言gets的用法

例:

void test7()

{

char str1[80];

char str2[80];

printf("please input aany 2 sentence:n");

gets(str1);

scanf("%s",str2);

printf("string1 is:%sn",str1);

printf("string2 is:%s",str2);

}

int _tmain(int argc, _TCHAR* argv[])

{

test7();

return 0;

}

輸入:hello world

hello world

執行結果爲:string1 is:hello world

string2 is :hello