Jump to content
  • Advertisement
Sign in to follow this  
Tallshortkid

Dev C++

This topic is 5090 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there anything different about using this compiler compared to others? are there any tutorials geared directly toward it because i am having some problems with it? Thx in advance

Share this post


Link to post
Share on other sites
Advertisement
Dev C++ is greta free compiler. I use and I like it. The only other think I would reccommend is VC++ and it costs money. So, freely speaking Dev C++ is one of the best.

What problems are you having?

(when posting a lot of lines of code put it between [.source] and [./source], leave out the dots. for less code(6 less lines) use [.code] [./code], without dots)

Share this post


Link to post
Share on other sites
I also use Dev C++ even though I have Borland 5.0. I dunno, I just like Dev C++ better. What sort of problems are you having?

Share this post


Link to post
Share on other sites
well my window pos up and when i put in my number and press enter the windows goes away really fast and if i dont put the
cin.get() in it it doesnt stay up soo hers the code


//MY simple dum prog
#include <iostream>
using namespace std;

int main() {
int number;
cout << "Please enter a number";
cin >> number;
cout << "\n Is this your number ";
cout << number;
cin.get(); //use this to keep your windo open
}

as you can see im just beginning so if anyone has a in-depth easy to understand tut for C++ can u give me a link

Share this post


Link to post
Share on other sites
Yes, when you write a console program, after it has done everything it's supposed to (it does print the output, it just closes to quickly for you to see it) it closes, it sees no reaosn to stay open. If you run it form another console window that window will stay open and you can see your result.

It's not a weird problem ro anything, that's how it always works. Don't worry about it; when you get to games you'll have exit buttons and gameloops and such.

Share this post


Link to post
Share on other sites
Just open through another console window. Open a DOS window if you're using Windows 98, 95, Me, etc. Exp is just 'console window'.

Then us the cd command to get to the programs directory and type the filename.

Example: My program is called 'test.exe' and is located in C:\Test Porjects\misc

C:\>cd 'C:\Test Projects\misc'
C:\Test Projects\misc\>test

(program runs)


You don't have to do this; just use system("PAUSE"); or cin.get();

Share this post


Link to post
Share on other sites
Quote:
Original post by Tallshortkid
well my window pos up and when i put in my number and press enter the windows goes away really fast and if i dont put the
cin.get() in it it doesnt stay up soo hers the code


//MY simple dum prog
#include <iostream>
using namespace std;

int main() {
int number;
cout << "Please enter a number";
cin >> number;
cout << "\n Is this your number ";
cout << number;
cin.get(); //use this to keep your windo open
}

as you can see im just beginning so if anyone has a in-depth easy to understand tut for C++ can u give me a link


You need to put another cin.get(); after the first one because there is still a '\n' in the input stream (stdin).

Or...use this tid bit:


...
fflush( stdin ); // #include <stdin.h> and <stdio.h>
system( "PAUSE" );
...

Share this post


Link to post
Share on other sites
well now i have

#include <iostream>
using namespace std;

int main() {

int number;
cout << "Press enter to exit";
while(cin.get() != '\n')
{
// Process according to your input
cout<< number;
}
return 0;
}


And it still closes before it prints out the numbers

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Or you could do this too



#include <iostream>
#include <conio.h>

using namespace std;

int main()
{
..code goes here

getch(); //wait for key
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!