作者windown (慢慢調適...)
看板C_and_CPP
標題[問題] 在DEV C++遇到的小問題...
時間Thu Dec 10 09:14:55 2009
我來補上我的程式碼
---------------------------------
#include <stdio.h>
int main()
{
int integer1;
int integer2;
int sum;
printf( "Enter first integer\n" );
scanf( "%d", &integer1 );
printf( "Enter second integer\n" );
scanf( "%d", &integer2 );
sum = integer1 + integer2;
printf( "Sum is %d\n", sum );
return 0;
}
當我comlile這段程式碼時
DEV顯示"DONE"
但當我要RUN這個程式時
他會出現程式視窗
但我一執行完就馬上消失
先前爬過文要在結束前加個system("PAUSE")
我照作並加在這...
------------------------------
.
.
.
.
(忽略)
sum = integer 1 + integer 2;
printf("sun is %d \n" , sun);
system("PAUSE");
return 0;
}
我重新compile他卻跟我說這個system未宣告
怎麼了嗎??
我還少了什麼東西嗎@@
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.134.228.82
1F:→ visor:#include <stdlib.h> 12/10 09:23
2F:→ windown:謝謝樓上!! 但我不懂原理...@@ 12/10 09:29
3F:→ visor:白話一點 system 這個 function 的長相 放在 stdlib.h 裡 12/10 09:49
4F:→ ianfang:跟你要include stdio.h 的原因一樣 12/10 10:56
5F:推 qDaniel:就是你要用system("pause")這個指令 要先宣告stdlib.h 12/10 12:39
6F:→ qDaniel:就像你要用printf 要先宣告stdio.h一樣 12/10 12:39