problems with Dev C++

Pages: 12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>

using namespace 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

Execution terminated
Compilation successful
Okay. Good to know.

-Albatross

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().
Sorry I didn't notice I didn't ask anything..lol

Okay, I did try the cin.ignore(); and I got the same thing. The window remains closed.

It tells me this:

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

Execution terminated
Compilation successful

Any ideas what I can do to keep the window open? Thanks for taking time to help :).
Last edited on
Okay. Try actually running your program after compiling it? If the last statement is "Compilation successful", then you probably haven't run your program.

-Albatross
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.

Any other Ideas would be appreciated.
In that case something's absolutely wrong with either your stdlib++ library or Dev-C++ and you need to get it fixed ASAP.

Or... what's the output when you compile and run it?

-Albatross

Not sure what you mean when you say whats the output as I am new to c++. it just runs real quick i see the window for just a micro second and that it.
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

Execution terminated
Compilation successful


I'm hoping for something like this but with at least one extra line that tells you something about the debugger.

-Albatross
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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  

Execution terminated
Compilation successful


No extra lines... just that. I am going to try to get a fresh version of dev c++...I'll let you know what happens.
Last edited on
Then you've got one messed up debugger, or else you're really not running the program. Really. Or else it's not terminating.

-Albatross
Okay, a fresh install fixed it. Do yourself a favor and don't get the Download.com one heh. Thanks for your ideas.. they help me alot.
...I'm running GNU/Linux.

You're welcome!

-Albatross
me again, I had a question involving my code. Here is my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>

using namespace 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 :).
I recommend using a switch statement coupled with a variable that you put your keypress into. cin.get() might be useful...
http://cplusplus.com/doc/tutorial/control/
http://cplusplus.com/reference/iostream/istream/get/

-Albatross
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.

-Albatross
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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

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.*/
Last edited on
Thanks for all your help, Okay I am still having a little trouble this is what I have now:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>

using namespace 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?
I tried putting choose in the cin.get (choose); But that also wouldn't work....any ideas?
Pages: 12