看板 C_and_CPP 關於我們 聯絡資訊
dev c++ 我用C++輸入程式 編輯後沒有錯誤再跑時出現 原始碼檔案無法編譯用 可是我改用用c語言可以 這是c++我按照範例打的 #include <cstdilb> #include <iostream> #include<fstream> using namespace std; int main() //int argc,char*argv[]) { int grade[5]; cin>>grade[0]>>grade[1]>>grade[2]>>grade[3]>>grade[4]; ofstream outFile("grade.dat",ios::out); outFile<<grade[0]<<grade[1]<<grade[2]<<grade[3]<<grade[4]; ifstream inFile("grade.dat",ios::in); inFile>>grade[0]>>grade[1]>>grade[2]>>grade[3]>>grade[4]; cout<<grade[0]<<""<<grade[1]<<""<<grade[2]<<""<<grade[3]<<""<<grade[4]<<endl; double average; average=(grade[0]+grade[1]+grade[2]+grade[3]+grade[4])/5.0; cout<<"平均成績="<<average<<endl; int max=grade[0]; if(max<grade[1]) max=grade[1]; if(max<grade[2]) max=grade[2]; if(max<grade[3]) max=grade[3]; if(max<grade[4]) max=grade[4]; cout<<"最高分="<<max<<endl; system("PAUSE"); return 0; } 再用另一個c++程式 //Calculate the area of the circle #include <iostream.h> #include <conio.h> const float PI = 3.14159; inline float circleArea(const float r){return PI*r*r;} main(){ clrscr(); cout << "Enter the radius of the circle:"; float radius; cin >> radius; cout << "The area of the circle with radius " << radius << " is " << circleArea(radius) << '\n'; getch(); return 0; } 也一樣 我也重灌過dev 結果也一樣 用c語言可以running 用c++就一直出現 原始碼檔案無法編譯 我上網也找過類似問題但 我用c語言打卻是可以 請教一下 我是哪裡錯了 thanks -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 210.240.176.170
legnaleurc:文法錯了 09/23 08:36
VictorTom:無法編譯就是compile有error吧?? 請學著看error message 09/23 09:01
VictorTom:, 最起碼也把錯誤訊息貼上, 不要讓大家用大腦幫你 09/23 09:02
VictorTom:compile找error....~_~ 09/23 09:02
ggosiang:(X)cstdilb (O)cstdlib 在第一行 09/23 14:51