Program runs but not visible

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Oct 2006
Posts: 179
Reputation: HLA91 is an unknown quantity at this point 
Solved Threads: 2
HLA91 HLA91 is offline Offline
Junior Poster

Program runs but not visible

 
0
  #1
Oct 7th, 2007
Hi all

I am totally new to C++ and I am using the Dev C++ compiler and getting the tutorial off
http://www.cplusplus.com/doc/tutoria...structure.html
I ran the first program (code below) and it compiled fine but when I run it a box appears then dissappears so quickly I dont have time to see what it is but by the black colour I assume its DOS, can anyone tell me why it is doing this please as I don't know if my program is working correctly and I tried the other examples and the same happens, am I doing something wrong is that why it dissappears so quickly?
  1. / my first program in C++
  2.  
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main ()
  7. {
  8. cout << "Hello World!";
  9. return 0;
  10. }

Many thanks

HLA91
You know your a geek, if you introduce your wife as "mylady@home.wife"
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Program runs but not visible

 
0
  #2
Oct 7th, 2007
You need to put a cin.get(); before the return 0;

Also the black window is commonly referred to as ze console window
Last edited by iamthwee; Oct 7th, 2007 at 3:19 pm.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 179
Reputation: HLA91 is an unknown quantity at this point 
Solved Threads: 2
HLA91 HLA91 is offline Offline
Junior Poster

Re: Program runs but not visible

 
0
  #3
Oct 7th, 2007
Ok thanks it works now but why didnt the tutorial tell me that, can you recommend a good tutorial for me?

Many thanks for quick reply

HLA91
You know your a geek, if you introduce your wife as "mylady@home.wife"
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Program runs but not visible

 
0
  #4
Oct 7th, 2007
> why didnt the tutorial tell me that

Because it ain't got nowt to do with c++, or the semantics of the language anyway. It depends on whether your IDE (integrated development environment) already has a built-in option to pause the program for viewing.

Some don't, some do.

If you ran your program from the command prompt there would be no need for the cin.get();.

>a good tutorial for me
There are a few useful snippets at daniweb. Look there. But ultimately the best way to learn is to try your hand at a problem and post your queries here.
Last edited by iamthwee; Oct 7th, 2007 at 3:31 pm.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 179
Reputation: HLA91 is an unknown quantity at this point 
Solved Threads: 2
HLA91 HLA91 is offline Offline
Junior Poster

Re: Program runs but not visible

 
-1
  #5
Oct 15th, 2007
I have come across another problem again, the code from another tutorial wont be visible
  1. // How IF Works#include <iostream>using namespace std;int main(){ cout << "Enter your age: "; int age; cin >> age; if (age < 20) cout << "You are still young!\n"; else cout << "You are not so young anymore.\n"; }
I did try placing cin.get(); before the closing bracket but that didn't work and I also added return 0; incase that helped but nope. Also I cant execute the programs on my laptop running windows Me when I type IF.exe when im in the folder it says syntax error is there something different with the DOS? Many thanks HLA91
You know your a geek, if you introduce your wife as "mylady@home.wife"
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,468
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1477
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Program runs but not visible

 
0
  #6
Oct 15th, 2007
Unbelievable. 75 posts and you still don't know how to format your code ! I certainly hope you do not plan to turn in that to your instructor.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 179
Reputation: HLA91 is an unknown quantity at this point 
Solved Threads: 2
HLA91 HLA91 is offline Offline
Junior Poster

Re: Program runs but not visible

 
0
  #7
Oct 16th, 2007
What do you mean I dont know how to format my code, if you mean placing it in my post I obviously can becasue I did it in the first post of this topic all you did was comress it which to me makes it harder to read. Also I wont be handing it to my instructor becasue this is a hobby not a school subject.
You know your a geek, if you introduce your wife as "mylady@home.wife"
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,468
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1477
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Program runs but not visible

 
0
  #8
Oct 16th, 2007
Originally Posted by HLA91 View Post
all you did was comress it which to me makes it harder to read. .
Nope -- we didn't do that. In the future please hit the Preview button before posting so that you can see what it looks like.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 8
Reputation: jansson is an unknown quantity at this point 
Solved Threads: 2
jansson jansson is offline Offline
Newbie Poster

Re: Program runs but not visible

 
0
  #9
Oct 16th, 2007
Because I'm such a sweet guy:
  1. // How IF Works
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7. cout << "Enter your age: ";
  8. int age;
  9. cin >> age;
  10. if (age < 20)
  11. cout << "You are still young!\n";
  12. else
  13. cout << "You are not so young anymore.\n";
  14.  
  15. return 0; //Yes I did put in 'return 0' because it's bad
  16. //practice to leave it out and yada yada yada...
  17. }

But to help you I guess we will nead a bit more info, the code should execute properly as it is. The problem of 'not visible', is it still in the ide?
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,745
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 739
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Program runs but not visible

 
0
  #10
Oct 16th, 2007
>//Yes I did put in 'return 0' because it's bad
>//practice to leave it out and yada yada yada...
You're not getting away with this one. Explain why it's a bad practice, please.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC