Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Extreme newbie
Index -> Programming, C++ -> C++ Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Newguy




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
zylum




PostPosted: Sat May 03, 2008 3:05 pm   Post subject: RE:Extreme newbie

You need to add a pause before the return.
Tony




PostPosted: 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 Laughing

You need to run the application from the terminal window (command prompt).
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
zylum




PostPosted: Sat May 03, 2008 3:14 pm   Post subject: RE:Extreme newbie

Ehh you're right, that's just me being lazy Laughing
Kharybdis




PostPosted: 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.
Newguy




PostPosted: 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 Laughing

You need to run the application from the terminal window (command prompt).


What do you mean by command prompt? I am stupid. Very Happy

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
Steven Toews




PostPosted: 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;
}
Newguy




PostPosted: 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;
Sponsor
Sponsor
Sponsor
sponsor
Saad




PostPosted: 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
Steven Toews




PostPosted: 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...
Saad




PostPosted: 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
Steven Toews




PostPosted: 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
Newguy




PostPosted: 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


Cool but I am a new person to C++ so I wouldn't worry too much about cross platform development. Smile What do you mean by using the command line?
Tony




PostPosted: 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Newguy




PostPosted: 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"
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 19 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: