exe檔 和c++的問題....

2008-02-02 9:40 am
本人用c++ 設計了一個程式,而且program中沒有錯誤,當run 了該program 並在桌面上出現了xxx.exe 的檔,但按了執行那exe檔只彈了半秒的,,,並不能正常的執行...

附上該 program::
#include
main()
{
char charry[] = "Hello";
printf("%s", charry);
return 0;
}

program應該沒有問題...但為什麼EXE檔開不了??
請問這是什麼事和有什麼方法可以令window 正常執行了exe檔??....(本人是window xp sp1)

回答 (2)

2008-02-02 2:49 pm
✔ 最佳答案
There is nothing wrong with the program. It executed correctly and terminated!

The problem is because there is nothing to stop the program for you to see the output. It displays the line and then the program terminates.
In cases like this, very often you would print a line at the end like:

...
printf("Press enter to exit program\n");
getchar();
return 0;
}

The program will wait for the user to key in a character before exiting, thus permitting him to see the display.
2008-02-04 3:31 am
你是不是開始學c++的呀???


#include
main()
{
char charry[] = "Hello";
printf("%s", charry);
int y;
cin >> y; (這樣就可以了,programme就會看到這code之後,會等使用者入一些數字,english(什麼都得)之就會關閉的......你睇下係唔係啦)
return 0;
}


仲有PROGRAMME沒有錯.....只是開左之後就關閉,多數新學都有這一個問題.......


如果錯了的話,你就原諒我吧


小弟12歲,對C++有一些知識........錯左就不要見怪
參考: 我自己都是新人.......一齊加油吧......


收錄日期: 2021-04-13 15:04:15
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20080202000051KK00249

檢視 Wayback Machine 備份