Problem in C++

Any other programming language that is not covered in the Web Scripting category.

Problem in C++

Postby djpac on Fri Aug 19, 2005 6:42 pm

I have this nice little program called: BloodShed Dev-C++. It seems like a great tool. I can compile everything that is needed, but when ever i run the program, the window(which looks like a cmd prompt window) pops up and disappears in less then a second. I can even see what it says on the window. Any one know how i can fix this problem so i can continue to learn C++ on my home computer?
I am using a Microsoft Windows XP Professional with Service Pack 2, its also a Dell.... not sure if that matters..
Image
djpac
Contributer
Contributer
 
Posts: 20
Joined: Thu Aug 18, 2005 7:35 pm
Location: Rhode Island

Postby Sn4keBite on Fri Aug 19, 2005 7:36 pm

I assume you're writing a console application. in that case, try adding the line
Code: Select all
system("pause");

at the end of your main() function
Sn4keBite
Newbie
Newbie
 
Posts: 12
Joined: Mon May 16, 2005 5:12 pm
Location: Norway

Postby nene on Sat Aug 20, 2005 5:04 pm

yes, the program just executes the code and then closes the window... you could also use cin or any other command to call input at the end of the program... but this is a little "unprofessional".. Smile
nene
Regular
Regular
 
Posts: 128
Joined: Wed Apr 13, 2005 10:24 am
Location: Slovenia

Re: Problem in C++

Postby pcweirdo on Tue Aug 30, 2005 12:22 am

djpac wrote:I have this nice little program called: BloodShed Dev-C++. It seems like a great tool. I can compile everything that is needed, but when ever i run the program, the window(which looks like a cmd prompt window) pops up and disappears in less then a second. I can even see what it says on the window. Any one know how i can fix this problem so i can continue to learn C++ on my home computer?
I am using a Microsoft Windows XP Professional with Service Pack 2, its also a Dell.... not sure if that matters..


adding system("pause") at the end can bite if you run the app outside development sometimes. If you open up cmd and then type the name of the compiled EXE file, it will show the output before dropping you back to the command prompt again.

-pcweirdo.
I love logic, therefore a polar bear is gay and I am the President. Or I'm thinking too much. I love this website.
pcweirdo
Contributer
Contributer
 
Posts: 58
Joined: Mon Aug 29, 2005 11:26 pm
Location: Melbourne, Australia

Postby asfura on Wed Aug 31, 2005 10:29 pm

i was going to askt the same thing... thx Wink
Its only me
asfura
Newbie
Newbie
 
Posts: 15
Joined: Wed Aug 31, 2005 1:58 am

Postby exezic on Sat Sep 03, 2005 9:59 am

Either pause, or try getting a nice screenshot of what happend, by using the Print Scrn button. (That's what I do Razz)
Image
exezic
Newbie
Newbie
 
Posts: 19
Joined: Sat Sep 03, 2005 9:29 am

Postby tonhao on Wed Sep 07, 2005 12:46 am

Why dont you simply use :
Code: Select all
getch();
at the end on the main() code
tonhao
Newbie
Newbie
 
Posts: 1
Joined: Wed Sep 07, 2005 12:38 am

Postby beetleflux on Sat Sep 10, 2005 5:09 pm

Since its a dos application its supposed to be ran in dos. So if you try to run it in dos you will see what has been printed. But if you doubleclick it, it just disappears.
beetleflux
Newbie
Newbie
 
Posts: 14
Joined: Sat Sep 10, 2005 4:57 pm
Location: Norway

Postby mm_freak on Tue Sep 13, 2005 12:34 am

Get familiar with getopt(3) and add a -d option to your program. From the IDE, run your program with the additional argument -d. Your program should call getchar(3) if -d has been specified. Anyway: getopt is a handy command line option parser, not only for debugging purposes. =)
I'm x^10 + x^8 + x^5 + x^4 + x^3 + 1, so don't mess with me!
mm_freak
Moderator
Moderator
 
Posts: 635
Joined: Sun Sep 11, 2005 12:29 pm
Location: Baden-Wuerttemberg (Germany)

Bloodshed ?!?!??

Postby hellais on Tue Sep 13, 2005 11:21 am

Bloodshed is a good program yet I would be much better if you installed a serious compiler such as gcc Razz
hellais
Newbie
Newbie
 
Posts: 2
Joined: Tue Sep 13, 2005 11:17 am

Re: Bloodshed ?!?!??

Postby mm_freak on Tue Sep 13, 2005 12:38 pm

hellais wrote:Bloodshed is a good program yet I would be much better if you installed a serious compiler such as gcc :P


Dev-C++ actually does use gcc, but the MinGW-version. =)
I'm x^10 + x^8 + x^5 + x^4 + x^3 + 1, so don't mess with me!
mm_freak
Moderator
Moderator
 
Posts: 635
Joined: Sun Sep 11, 2005 12:29 pm
Location: Baden-Wuerttemberg (Germany)

Postby thoriumbr on Tue Sep 13, 2005 7:20 pm

bloodshed is only an IDE... it can use gcc, microsoft c++, borland c++ builder and djgpp as a compiler...
thoriumbr
Contributer
Contributer
 
Posts: 26
Joined: Tue Aug 23, 2005 1:49 pm
Location: Limeira, SP, Brazil

Postby mm_freak on Tue Sep 13, 2005 10:17 pm

Yes, but it comes with gcc by default. And you'd never have any reason to change it. At least, if you want to program in real C++. =)
I'm x^10 + x^8 + x^5 + x^4 + x^3 + 1, so don't mess with me!
mm_freak
Moderator
Moderator
 
Posts: 635
Joined: Sun Sep 11, 2005 12:29 pm
Location: Baden-Wuerttemberg (Germany)

Postby peterskate on Tue Jun 20, 2006 11:17 pm

C++ is owning IRC bots Very Happy
peterskate
Newbie
Newbie
 
Posts: 15
Joined: Thu Apr 13, 2006 5:22 pm

Postby peterskate on Tue Jun 20, 2006 11:18 pm

RE : I'm x^10 + x^8 + x^5 + x^4 + x^3 + 1, so don't mess with me!
What means that ??? Confused
peterskate
Newbie
Newbie
 
Posts: 15
Joined: Thu Apr 13, 2006 5:22 pm

Next

Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron