Author |
Message |
Newguy
|
Posted: Sat May 03, 2008 3:04 pm Post subject: Extreme newbie |
|
|
Ok I am extremely new to C++ and I managed to get my hands on a copy of Visual Basic C++ (the latest version) for free. I created a new project as a "General" prject adn it is empty. Then I added a new item as a .cpp file. Then I entered basic code to display a message as:
Quote: #include <iostream>
using namespace std;
int main ()
{
cout <<"This is my first C++ program.";
return 0;
}
I can't seem to find the run button to make it work. Should I be looking for a run button. Do I need to enter a command? I have no idea. Right now I compile it (shows it as 1 succeded) and run it by pressing on "Debug". When I do this, the Win32 window shows up, maybe for 1 second, and then quickly disappears. How can I run it or get it to show up constantly. Thanks for answering this extreme newb question. ![Very Happy Very Happy](http://compsci.ca/v3/images/smiles/icon_biggrin.gif) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
zylum
![](http://compsci.ca/v3/uploads/user_avatars/1689129126468091c334ee0.gif)
|
Posted: Sat May 03, 2008 3:05 pm Post subject: RE:Extreme newbie |
|
|
You need to add a pause before the return. |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Sat May 03, 2008 3:10 pm Post subject: Re: RE:Extreme newbie |
|
|
zylum @ Sat May 03, 2008 3:05 pm wrote: You need to add a pause before the return.
That's wrong. And zylum, you should know better
You need to run the application from the terminal window (command prompt). |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
zylum
![](http://compsci.ca/v3/uploads/user_avatars/1689129126468091c334ee0.gif)
|
Posted: Sat May 03, 2008 3:14 pm Post subject: RE:Extreme newbie |
|
|
Ehh you're right, that's just me being lazy ![Laughing Laughing](http://compsci.ca/v3/images/smiles/icon_lol.gif) |
|
|
|
|
![](images/spacer.gif) |
Kharybdis
![](http://compsci.ca/v3/uploads/user_avatars/111642592477ec7e78e574.gif)
|
Posted: Sat May 03, 2008 3:58 pm Post subject: Re: Extreme newbie |
|
|
Build the solution first, then run it without debugging from the debug menu. |
|
|
|
|
![](images/spacer.gif) |
Newguy
|
Posted: Sat May 03, 2008 7:19 pm Post subject: Re: RE:Extreme newbie |
|
|
zylum @ Sat May 03, 2008 3:05 pm wrote: You need to add a pause before the return.
That is what I am doing right now because I just figured out how to get input from the user.
Tony wrote:
zylum @ Sat May 03, 2008 3:05 pm wrote: You need to add a pause before the return.
That's wrong. And zylum, you should know better
You need to run the application from the terminal window (command prompt).
What do you mean by command prompt? I am stupid.
Kharybdis wrote:
Build the solution first, then run it without debugging from the debug menu.
Tried building the solution and ran it without debugging from the debug menu but it still quits on me.
Thanks for your help and quick responses. But I still need help. Thanks guys. ![Smile Smile](images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
Steven Toews
|
Posted: Sun May 04, 2008 3:48 am Post subject: Re: Extreme newbie |
|
|
Ok so.... Use this to have it say "press any key to continue" system("PAUSE");
Here is the proper code:
#include <iostream>
using namespace std;
int main ()
{
cout <<"This is my first C++ program.";
cout<<endl; // This just drops it down a line to print words
system("PAUSE"); // This pauses the script until a key is pressed
return 0;
} |
|
|
|
|
![](images/spacer.gif) |
Newguy
|
Posted: Sun May 04, 2008 10:01 am Post subject: Re: Extreme newbie |
|
|
Steven Toews @ Sun May 04, 2008 3:48 am wrote: Ok so.... Use this to have it say "press any key to continue" system("PAUSE");
Here is the proper code:
#include <iostream>
using namespace std;
int main ()
{
cout <<"This is my first C++ program.";
cout<<endl; // This just drops it down a line to print words
system("PAUSE"); // This pauses the script until a key is pressed
return 0;
}
Awesome I will use that. Thanks. Right now I am just doing
int stop;
cin >>stop;
return 0; |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Saad
![](http://compsci.ca/v3/uploads/user_avatars/182387547249e7ebb91fb8a.png)
|
Posted: Sun May 04, 2008 10:16 am Post subject: Re: Extreme newbie |
|
|
Newguy @ Sun May 04, 2008 10:01 am wrote: Steven Toews @ Sun May 04, 2008 3:48 am wrote: Ok so.... Use this to have it say "press any key to continue" system("PAUSE");
Here is the proper code:
#include <iostream>
using namespace std;
int main ()
{
cout <<"This is my first C++ program.";
cout<<endl; // This just drops it down a line to print words
system("PAUSE"); // This pauses the script until a key is pressed
return 0;
}
Awesome I will use that. Thanks. Right now I am just doing
int stop;
cin >>stop;
return 0;
Actually, I would not use that. What you have with the cin >> stop is better then system ("PAUSE"). system ("PAUSE") only works with windows, while cin >> stop is cross platform |
|
|
|
|
![](images/spacer.gif) |
Steven Toews
|
Posted: Sun May 04, 2008 10:22 am Post subject: Re: Extreme newbie |
|
|
Sure it's cross platform but it's cheating. You can't just call for a variable everytime you want to pause when a pause function exists... |
|
|
|
|
![](images/spacer.gif) |
Saad
![](http://compsci.ca/v3/uploads/user_avatars/182387547249e7ebb91fb8a.png)
|
Posted: Sun May 04, 2008 10:25 am Post subject: Re: Extreme newbie |
|
|
Steven Toews wrote:
Sure it's cross platform but it's cheating. You can't just call for a variable everytime you want to pause when a pause function exists...
In which case, cin.get() is also there. On another note using the command line is a better alternative |
|
|
|
|
![](images/spacer.gif) |
Steven Toews
|
Posted: Sun May 04, 2008 10:29 am Post subject: RE:Extreme newbie |
|
|
Alright, conclusion reached. If your cross platform developing, or dont want it to say "press any key to continue..." then cin.get() is a greate way to do it. ![Smile Smile](http://compsci.ca/v3/images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
Newguy
|
Posted: Sun May 04, 2008 12:25 pm Post subject: Re: RE:Extreme newbie |
|
|
Steven Toews @ Sun May 04, 2008 10:29 am wrote: Alright, conclusion reached. If your cross platform developing, or dont want it to say "press any key to continue..." then cin.get() is a greate way to do it. ![Smile Smile](http://compsci.ca/v3/images/smiles/icon_smile.gif)
Cool but I am a new person to C++ so I wouldn't worry too much about cross platform development. What do you mean by using the command line? |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Sun May 04, 2008 12:56 pm Post subject: Re: RE:Extreme newbie |
|
|
Newguy @ Sun May 04, 2008 12:25 pm wrote: I wouldn't worry too much about cross platform development.
You should.
The command prompt is the terminal window you get when you go to Start -> run -> cmd |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
Newguy
|
Posted: Sun May 04, 2008 1:21 pm Post subject: Re: RE:Extreme newbie |
|
|
Tony @ Sun May 04, 2008 12:56 pm wrote: Newguy @ Sun May 04, 2008 12:25 pm wrote: I wouldn't worry too much about cross platform development.
You should.
The command prompt is the terminal window you get when you go to Start -> run -> cmd
I know what the command prompt is I don't know what he meant by "using the command line" |
|
|
|
|
![](images/spacer.gif) |
|