0
我使用OSX終端來編譯和運行我的C代碼。OSX終端不接受來自簡單程序的輸入
由於某種原因,每當我想從使用OSX終端的程序輸入輸入,而不是讓我鍵入輸入(例如字符串)時,終端實際上將我的代碼的第一行作爲輸入。奇怪的!
我將展示我的簡單程序和我的輸出外觀。
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
int main(void){
char text[100];
printf("Type a text: \n");
gets(text);
printf("%s\n",text);
return 0;
}
我從終端輸出:
Type a text:
warning: this program uses gets(), which is unsafe.
#include <stdio.h>
適用於我的10.8 ... – Eugene
您是如何執行該程序的? –
gcc「文件名」 ./a.out <「文件名」 – rlima1877