Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 01-01-2006, 11:52 PM   #1
Member (9 bit)
 
Hags's Avatar
 
Join Date: Apr 2004
Location: Woburn, MA
Posts: 402
C++ Question

I did not see any other forums with c++ as a possible subject so I am taking it here. I am just starting to learn the programming language. Now I am sure anyone even a little experienced with C++ knows about the "Hello World" program that almost everyone writes as a first practice code. I am using Dev C++ as a compiler just in case this helps. Now whenever I write the hello world program, it compiles and runs fine but it only flashes on the screen for a very breif second. Now I know there is a line of code you can insert at the bottom of your project to make the dos prompt type window stay open so you can read your project but I forgot what it is. Does anybody know what the line of code to make the dos window stay open so I can see what I've done?
Hags is offline   Reply With Quote
Old 01-02-2006, 12:15 AM   #2
glc
Forum Administrator
Staff
Premium Member
 
glc's Avatar
 
Join Date: May 2000
Location: Joplin MO
Posts: 37,786
Moved to.......

Web Development & Hosting
Questions about HTML, CSS, Javascript, Java, MySQL, PHP, Perl, general programming, and Web Hosting. Want to know what others think of your site? Ask here..
glc is offline   Reply With Quote
Old 01-02-2006, 03:02 AM   #3
Member (9 bit)
 
Join Date: Feb 2005
Posts: 392
use "getchar()"
example:

include< cstdio >
include ...
.....
do whatever output line

....... then in the end:

getchar(); // equivalent to PAUSE in DOS

----------------------
the above line stop the program for as long as you wanted until you press a key on the keyboard.
__________________
words to live by:
others don't know, I know.
others know, I know more.
others know more, I excel.
one shouldnt read this far; above, is meant as an encouragement, translated from a Chinese Proverb.
"He who angers you conquers you." : Elizabeth Kenny

Last edited by alfie2; 01-02-2006 at 03:19 AM.
alfie2 is offline   Reply With Quote
Old 01-02-2006, 03:03 AM   #4
Member (7 bit)
 
Join Date: Dec 2005
Posts: 87
I written batch programs before that output directly to the console and to do this I just wrote PAUSE. Hope it helps.

On a personal note I found it easier to start with managed code like C#. Here is a link to some great tutorial videos:

http://msdn.microsoft.com/vstudio/ex...g/default.aspx

I just thought the managed code seemed similar, plus this is running on Microsoft .NET 2.0. I don't know if Dev C++ is the newest one.

Also you can get C# Visual Express for free and it allows you to develop MS SQL Server applications completly free of charge. It's pretty cool.
hartken is offline   Reply With Quote
Old 01-02-2006, 03:43 AM   #5
Member (10 bit)
 
Join Date: Mar 2003
Location: Nottingham UK or Kuala Lumpur Malaysia
Posts: 600
Send a message via ICQ to rave Send a message via AIM to rave Send a message via MSN to rave Send a message via Yahoo to rave
add the header: #include
add this line before your "return 0" : getch();

*edit: wait...sorry. dunno if this will work. i do C only. you can try it though*
rave is offline   Reply With Quote
Old 01-02-2006, 08:02 AM   #6
Member (9 bit)
 
Hags's Avatar
 
Join Date: Apr 2004
Location: Woburn, MA
Posts: 402
cool, thanks guys, the getchar(); worked like a dream, I haven't tried pause yet but I wil, thanks again
Hags is offline   Reply With Quote
Old 01-03-2006, 04:52 PM   #7
Wx geek
 
blue60007's Avatar
 
Join Date: Aug 2005
Location: Indiana
Posts: 6,638
Also, try loading the program from the command prompt. That'll keep the text up there. What OS are you using?
__________________
"It is the way of man to make monsters and it is the nature of monsters to destroy their makers."
blue60007 is offline   Reply With Quote
Old 01-04-2006, 06:59 AM   #8
Member (9 bit)
 
Hags's Avatar
 
Join Date: Apr 2004
Location: Woburn, MA
Posts: 402
Running XP Pro
Hags is offline   Reply With Quote
Old 01-04-2006, 05:12 PM   #9
Wx geek
 
blue60007's Avatar
 
Join Date: Aug 2005
Location: Indiana
Posts: 6,638
You could start up the command prompt (Win Key + R), type in cmd and then you can navigate folders in the command prompt to the folder with the executable in. Use cd _folder name_/_sub folder_ and ../ to navigate up (Like C:/Documents and Settings to C:/). Then type in the name of the executable once your in the project folder.
blue60007 is offline   Reply With Quote
Old 01-05-2006, 04:27 AM   #10
Member (9 bit)
 
Join Date: Feb 2005
Posts: 392
Hags , Blue60007:

I dont think, that will work with programs compiled using Windows-based compilers; it will work with DOS based compilers.
because a Windows-based compiler will create a executable which will open a "child window" when you run/executed it. therefore same thing happens....window open prints output, then closes window.
alfie2 is offline   Reply With Quote
Old 01-05-2006, 03:52 PM   #11
Wx geek
 
blue60007's Avatar
 
Join Date: Aug 2005
Location: Indiana
Posts: 6,638
You sure? I've never used Dev C++ so I don't know how that works.

I'm using VS .NET 2003 and I can run programs as I described just fine.
blue60007 is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 05:02 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2