انجمنهای فارسی اوبونتو
کمک و پشتیبانی => برنامهسازی => نویسنده: arvinall در 02 آذر 1391، 03:58 بظ
-
من دارم c++ یاد میگیرم
اولین برنامه که اومدم بنویسم به مشکل بر خوردم
gcc هیچ کتابخانه ایی رو نمیشناسه
من دوتا اینکلاد کرم
iostream.h
fstream.h
که این ارور رو میده :
start.cpp:1:22: fatal error: iostream.h: No such file or directory
compilation terminated.
ممنون میشم اگه سریع بگید چون کتاب که گرفت صفحه هاش زیاده و باید تا یک هفته تموم شه
-
فایلهای سرآمد دیگر h ندارد
iostream
fstream
string
vector
-
این کد:
#include <iostream>
using namespace std;
int main(int argc, char* argv[]) {
cout << "salam" << endl;
}
و برای پردازش:
g++ salam.cpp
-
مرسی اون مشکل حل شد ولی باز ارور میده :
code:#include <iostream>
#include <fstream>
void CalcPay(float,float,float&);
const float MAX_HOURS = 40.0;
const float OVERTIME = 1.5;
int main(){
float payRate;float hours;float wages;float total;int empNum;ofstream payFile;
payFile.open("payfile.dat");
total = 0.0;
cout << "enter employee number: ";
cin >> empNum;
while (empNum != 0){
cout << "enter pay rate: ";cin >> payRate;
cout << "enter hours worked: ";cin >> hours;
CalcPay(payRate,hours,wages);
total = total + wages;
payFile << empNum << payRate << hours << wages;
cout << "enter employee number: ";cin >> empNum;
}
cout << "total payroll is " << total << endl;
return 0;
}
void CalcPay(/* in */ float payRate,/* in */ float hours,/* in */ float wages){
if (hours > MAX_HOURS) wages = (MAX_HOURS * payRate) + (hours - MAX_HOURS) * payRate * OVERTIME;
else wages = hours * payRate;
}
error:start.cpp: In function ‘int main()’:
start.cpp:7:62: error: ‘ofstream’ was not declared in this scope
start.cpp:7:62: note: suggested alternative:
In file included from /usr/include/c++/4.7/ios:39:0,
from /usr/include/c++/4.7/ostream:40,
from /usr/include/c++/4.7/iostream:40,
from start.cpp:1:
/usr/include/c++/4.7/iosfwd:162:34: note: ‘std::ofstream’
start.cpp:7:71: error: expected ‘;’ before ‘payFile’
start.cpp:8:1: error: ‘payFile’ was not declared in this scope
start.cpp:10:1: error: ‘cout’ was not declared in this scope
start.cpp:10:1: note: suggested alternative:
In file included from start.cpp:1:0:
/usr/include/c++/4.7/iostream:62:18: note: ‘std::cout’
start.cpp:11:1: error: ‘cin’ was not declared in this scope
start.cpp:11:1: note: suggested alternative:
In file included from start.cpp:1:0:
/usr/include/c++/4.7/iostream:61:18: note: ‘std::cin’
start.cpp:20:41: error: ‘endl’ was not declared in this scope
start.cpp:20:41: note: suggested alternative:
In file included from /usr/include/c++/4.7/iostream:40:0,
from start.cpp:1:
/usr/include/c++/4.7/ostream:562:5: note: ‘std::endl’
-
مرسی اون مشکل حل شد ولی باز ارور میده :
مشکل شما با نوشتن سطر پایین درست پیش از int main باید حل بشه:
using namespace std;
اگر به برنامهٔ نمونهای که پیشتر نوشته بودم دقت کنید هم همین سطر رو میبینید.
-
مگه از اکلیپس استفاده نمیکنی؟ اگه نه جفای بزرگی به خودت میکنی
-
مگه از اکلیپس استفاده نمیکنی؟ اگه نه جفای بزرگی به خودت میکنی
nano :دی
-
ببخشید ولی شما build-essential رو نصب کردین اصن ؟ واسه header فایل ها !؟