Dev C++ not working fine

So I downloaded Dev C++ which is very hard to use since at our Programming class, we use MS Visual Studio 6.0 and it's not a freeware so i can't download online.
My problem with Dev C++ is that my codes run but it closes when I enter something.
Also, are there anymore IDE/compiler as alternative for MS VS 6.0?
Write this before return statement
 
system("PAUSE");


Other FREE c++ IDE are:
codeblocks: www.codeblocks.org

msvc++ Express: www.msdn.com

Expert will tell you more.
I already tried adding that code. I don't know where to put it. And it doesn't work.
Give me your code here..i have DEV C++ too.
look at this....
1
2
3
4
5
6
7
8
9
10
11
12
#include<iostream>
#include<string>
using namespace std;

int main(){
string fname;
cout<<"Your  first name please: "<<endl;
cin>>fname;
system("PAUSE");
return 0;
}
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
//Exercise 14
#include <iostream.h>
#include <string> 
#include <limits>
int main ()

{
	char cc;

	cout <<"Enter course code:";
	cin >> cc;

	if ((cc=='a') || (cc=='A'))
		cout <<"Accounting" << endl;

	else if ((cc=='b') || (cc=='B'))
		cout <<"Banking and Finance" << endl;

	else if ((cc=='c') || (cc=='C'))
		cout <<"BSIT" << endl;

	else 
		cout <<"Invalid course" << endl; 

	return 0;

}
Last edited on
HERE the solution..but i thinks there is no need to include these
1
2
#include <string> 
#include <limits> 


your program will be..

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
	//Exercise 14
#include <iostream.h>

int main ()

{
	char cc;

	cout <<"Enter course code:";
	cin >> cc;

	if ((cc=='a') || (cc=='A'))
		cout <<"Accounting" << endl;

	else if ((cc=='b') || (cc=='B'))
		cout <<"Banking and Finance" << endl;

	else if ((cc=='c') || (cc=='C'))
		cout <<"BSIT" << endl;

	else 
		cout <<"Invalid course" << endl; 
		
system("PAUSE");
	return 0;

}
I think we can be friend-after you PM me.
Thanks. It works now.

Also, since I'm too lazy to make a new thread, WHEN will you include the <string>?
Our stupid instructor didn't teach us.
<string>


Is used when you need to create string datatype, like in my sample above i needed to take user name which is string---I included <string> library because string is not fundamental datatype as float ,double...e.t.c

try to delete it...
I had the problem again! Some of my codes doesn't work using system("PAUSE");
Our instructor never taught us to use that code! Do I really need to put that code on EVERY program I make on DevC++!?
The closing down isn't due to devc++...

it's just an ide, so it works correct, only if you do correct coding (just like all ide's and programs)..

What you need to do is add cin.ignore(numeric_limits<streamsize>::max(), '\n');

What this does is wait for enter to be pressed.. This is better then system("pause")...

And yes, you need to place something like this in every program, unless you want it to run successfully and then close down. What this (and system(pause)) does is wait for the user to press enter when ready. So now the program has to wait with closing down until the user presses enter :)

Cheers!
I'm using MVC++ 2010 Express for my IDE and it doesn't exit programs as soon as they're done so it can be to do with the IDE you're using. One thing you can do is create a batch file in Notepad witch contains two lines, the program name (e.g. Hello_world.exe) and 'pause' then save it with the .bat extension. That should stop it from exiting immediately at the finish if you double click that batch file or you could use a different IDE that automatically keeps open the command window.
okay!i was out..i think you can ask user to enter some value to exit.example.
1
2
3
4
int x;
do{cout<<"enter 3 to exit";
//your code goes here.
}while(x==3)
Topic archived. No new replies allowed.