#include <iostream>
usingnamespace std;
int Strength;
int main()
{
cout << "Your adventure starts in a little town called Garkos's Ferry more than 30 miles west of Crato./n";
cout << "The small town was once a booming city due to it's trade rout up and down its now dried up river bed./n";
cin.get();return 0;
}
As you can see from above I added the cin.get(); but the window will not come open. Here is what it tells me:
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\Makefile.win" all
g++.exe main.o Story.o -o "Stevie's First C++ Game.exe" -L"C:/Dev-Cpp/lib" -mwindows
g++.exe main.o Story.o -o "Stevie's First C++ Game.exe" -L"C:/Dev-Cpp/lib" -mwindows
g++.exe main.o Story.o -o "Stevie's First C++ Game.exe" -L"C:/Dev-Cpp/lib" -mwindows
g++.exe main.o Story.o -o "Stevie's First C++ Game.exe" -L"C:/Dev-Cpp/lib" -mwindows
P.S.- Most of us here will give you an annoying comment if your question doesn't exist or is ambiguous. However, I recommend that you try cin.ignore().
Okay. Try actually running your program after compiling it? If the last statement is "Compilation successful", then you probably haven't run your program.
Okay I just tried compiling it then after that I ran it.. but no change in what it is doing what so ever. Before I was doing compile and run but again it does the same thing.
#include <iostream>
usingnamespace std;
int Blacksmith;
int MagicUser;
int Thief;
int Warrior;
int main()
{
int Blacksmith = 1;
int MagicUser2 = 2;
int Thief = 3;
int Warrior = 4;
cout << "\n \n \t Your adventure starts in a little town called Garkos's Ferry.\n";
cout << " You were born in this town and was raised as a:\n";
cout << "\n 1. Blacksmith \n 2. Magic User \n 3. Thief \n 4. Warrior\n";
cin >> Blacksmith >> MagicUser >> Thief >> Warrior;
if(Blacksmith = true)
{
cout << "\nYou are a Blacksmith!\n";
}
cin.ignore();
return 0;
}
Okay I am very new at this, so bare with me heh, I am trying to get the if statement to, when the player presses the #1 key it will say you are a Blacksmith. Apparently that's not what my code tells it to do..lol. How would I do when a key is pressed if statement? Thanks in advance :).
Okay I checked out those links... they were very helpful, thanks for pointing them out. So this is what I got from it:
switch (1 is pressed)
{
case 1: Blacksmith
cout << "You have selected Blacksmith!";
break;
default:
cout << "Choose a number?";
}
Will the above do what I am needing? Never mind that didn't work..lol I got errors when I ran it. I guess I just don't know the syntax for what equals: When 1 is pressed.
Just input your variable name. I recommend axing every single variable you have within main(), and creating a new int that will receive your input from cin.get().
Then, put that variable name inside your switch(). Then, use the cases to determine what to do depending on the variable's value.
I don't understand this part: creating a new int that will receive your input from cin.get(). I don't know what that means. I am still very new to scripting. thanks if you could explain that futher.
int main()
{
int Blacksmith = 1;
int MagicUser2 = 2;
int Thief = 3;
int Warrior = 4;
int ClassChoice;
cin >> Blacksmith >> MagicUser >> Thief >> Warrior; /*This will request input of
an integer type, 4 times in a row.*/
cin >> ClassChoice; /*This will request input of an integer,
next you can check which value the user
has typed as input, and then run actions according to the value.*/
#include <iostream>
usingnamespace std;
int Blacksmith;
int MagicUser;
int Thief;
int Warrior;
int main()
{
int Blacksmith = 1;
int MagicUser = 2;
int Thief = 3;
int Warrior = 4;
cout << "\n \n \t Your adventure starts in a little town called Garkos's Ferry.\n";
cout << " You were born in this town and was raised as a:\n";
cout << "\n 1. Blacksmith \n 2. Magic User \n 3. Thief \n 4. Warrior\n";
cin >> Blacksmith >> MagicUser >> Thief >> Warrior;
int choose;
cin >> choose;
cin >> Blacksmith >> MagicUser >> Thief >> Warrior;
switch (choose)
{
case 1:
cout << "You have selected Blacksmith!\n";
break;
case 2:
cout << "You have selected Magic User!\n";
break;
case 3:
cout << "You have selected Thief!\n";
break;
case 4:
cout << "You have selected Warrior!\n";
break;
default:
cout << "Choose a number?\n";
}
cin.get();
return 0;
}
Basically, it lets me type in a number and hit enter, but it don't check and see which number they have selected. Doesn't the switch statement do that?