Overly Chatty Penguins
The Ready Room => Off Topic => Topic started by: Isamil on January 28, 2004, 03:50:28 PM
-
I'l update this whenever I change the code.
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
int score;
score = 0;
string help;
string thehelp;
string one;
string two;
string three;
string four;
string five;
thehelp = "You will be given questions about Social Studies. When you get the question, you get 3 choices. You will then press A, B, or C and hit enter. You move onto the next question, and if you got the last question right, you will get a point.";
cout<<"Welcome to the Social Studies game"<<endl;
cout<<"If you want to learn how to play, press A. If you want to play, press B"<<endl;
cin>>help;
if(help == "A") {
cout << thehelp <<endl;
}
else( help == "B") {
cout<<"First question"<<endl;
cout<<"Who were carpetbaggers?"<<endl;
cout<<"\tA:People who made carpet"<<endl;
cout<<"\tB:People who went into the south looking to become rich"<<endl;
cout<<"\tC:A type of bird"<<endl;
cin>>one;
}
if (one == "B") {
score++;
}
else() {
}
system("PAUSE");
return 0;
}
What is wrong with my code?
-
Try this:
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
int score;
score = 0;
string help;
string thehelp;
string one;
string two;
string three;
string four;
string five;
thehelp = "You will be given questions about Social Studies. When you get the question, you get 3 choices. You will then press A, B, or C and hit enter. You move onto the next question, and if you got the last question right, you will get a point.";
cout<<"Welcome to the Social Studies game"<<endl;
cout<<"If you want to learn how to play, press A. If you want to play, press B"<<endl;
cin>>help;
if(help == "A") {
cout << thehelp <<endl;
}
else if( help == "B") {
cout<<"First question"<<endl;
cout<<"Who were carpetbaggers?"<<endl;
cout<<"\tA:People who made carpet"<<endl;
cout<<"\tB:People who went into the south looking to become rich"<<endl;
cout<<"\tC:A type of bird"<<endl;
cin>>one;
if (one == "B") {
score++;
}
}
system("PAUSE");
return 0;
}
Disclaimer: I don't really know C++, so I'm just guesstimating.
-
Did that:
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/include/c++" -I"C:/Dev-Cpp/include/c++/mingw32" -I"C:/Dev-Cpp/include/c++/backward" -I"C:/Dev-Cpp/include"
main.cpp: In function `int main(int, char**)':
main.cpp:24: parse error before `{' token
main.cpp: At global scope:
main.cpp:36: ISO C++ forbids declaration of `system' with no type
main.cpp:36: `int system' redeclared as different kind of symbol
C:/Dev-Cpp/include/stdlib.h:373: previous declaration of `int system(const
char*)'
main.cpp:36: invalid conversion from `const char*' to `int'
main.cpp:37: parse error before `return'
make.exe: *** [main.o] Error 1
Execution terminated
-
Ok it works now, I'l post again if something else comes up.