Potrzebuję skompilować kod na moim systemie Linux. Jest to prosty kod i nie wiem co jest nie tak:Nie mogę skompilować C++ z gcc
Mam ten kod i nie mogę go skompilować:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string char1, char2, char3, char4, char5, char6;
cout<<"Hello this is your standard True and False quiz"<<endl;
cout<<"Please enter 'T' or 'F'"<<endl;
cout<<"No#1 George Washington invented the toilet?"<<endl;
cin>>char1;
if (char1 != "T" || "F")
{
cout<<"You entered an incorrect character please reenter True of False"<<endl;
cin>>char1;
}
if (char1 != "T" || "F")
{
cout<<"You entered an incorrect character please reenter True of False"<<endl;
cin>>char1;
}
if (char1 == "T")
{
cout<<"You entered the incorrect answer. The answer is False"<<endl;
}
cout<<"No#2 The Squareroot of 3136 is 56?"<<endl;
cin>>char2;
if (char2 != "T" || "F")
{
cout<<"You entered an incorrect character please reenter True of False"<<endl;
cin>>char2;
}
if (char2 != "T" || "F")
{
cout<<"You entered an incorrect character please reenter True of False"<<endl;
cin>>char2;
}
if (char2 == "F")
{
cout<<"You entered the incorrect answer. The answer is True"<<endl;
}
cout<<"No#3
system("PAUSE");
return 0;
}
Gdy próbuję go skompilować:
gcc file.c
Otrzymuję:
test.c:1: fatal error: iostream: No such file or directory
compilation terminated.
O ile mi wiadomo, mam wszystkie potrzebne biblioteki, co robię źle?
[pozbyć się 'system ("PAUSE");'!] (Http://www.gidnetwork.com/ b-61.html) –
'system (" PAUSE ")' działa poprawnie na Windowsie (MinGW i Cygwin powinny być z nim w porządku). Ale tak, przerwie to w Linuksie. – cHao
@ cHao: Jest to również jeden z najbardziej absurdalnych sposobów oczekiwania przed wyjściem programu.Tarła cały oddzielny proces, tylko czekać ?! Może być zaimplementowany w kilku liniach kodu! – dreamlax