Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
probblem with c++

 
Post new topic   Reply to topic Printable version
 View previous topic  song length (php/javascript) Post :: Post batch files are it beter version of c++?  View next topic  
Author Message
hellzlaker
Registered Cap Buster
Popping men in the ass since Oct 2005


Gender: NEVER ENOUGH!
Joined: Oct 27 2005
Posts: 34
Offline

PostPosted: Thu Nov 16, 2006 6:35 pm    Post subject: probblem with c++ Reply to topic Reply with quote

Code: Show/Hide
// my first program in C++

#include <iostream>
using namespace std;

int main ()
{
  cout << "Hello World!";
  return 0;
}


when i enter it in c++ it compiles it fine, but when i run it it closes... need help

also all of other stuf that i compile doesnt work like
Code: Show/Hide
// my second program using variables

#include <iostream>
using namespace std;

int main ()
{
    //telling variables
    int a,b;
    int result;
   
    //variable values and process
    a = 5;
    b = 2;
    a = a + 1;
    result = a - b;
   
    //show the result
    cout<< result;
   
    //turn off the program function
    return 0;
}
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address MSN Messenger
BDwinsAlt
Agurus's Posse


Age:33
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Thu Nov 16, 2006 7:22 pm    Post subject: Reply to topic Reply with quote

Code: Show/Hide

// my first program in C++

#include <iostream>
#include <stdlib.h> // Used for system commands like pause
using namespace std;

int main ()
{
  cout << "Hello World!";
  system("pause");    // Pauses the console screen.
  return 0;
}


Another way to do it is to check for input after the program is done running so they have to push enter before it closes the program.

Also after 'cout' space between the 'cout' and '<<' so cout<< should be cout <<.


Last edited by BDwinsAlt on Thu Nov 16, 2006 7:25 pm, edited 1 time in total
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
hellzlaker
Registered Cap Buster
Popping men in the ass since Oct 2005


Gender: NEVER ENOUGH!
Joined: Oct 27 2005
Posts: 34
Offline

PostPosted: Thu Nov 16, 2006 7:24 pm    Post subject: Reply to topic Reply with quote

is it only my computer that does that? because last year when i started c++ i dint need the pause function..
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address MSN Messenger
BDwinsAlt
Agurus's Posse


Age:33
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Thu Nov 16, 2006 7:26 pm    Post subject: Reply to topic Reply with quote

I'm pretty sure it depends on the compiler. With Dev C++ I had to, with Visual Studio .NET 2003 I don't have to.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Muskrat
Server Help Squatter


Age:36
Joined: Aug 24 2004
Posts: 829
Location: Swamp
Offline

PostPosted: Thu Nov 16, 2006 9:27 pm    Post subject: Reply to topic Reply with quote

ya know if you ran it from a command line it wouldn't disappear, that's why it dosent close in visual studio either....
Back to top
View users profile Send private message Add User to Ignore List AIM Address
BDwinsAlt
Agurus's Posse


Age:33
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Thu Nov 16, 2006 9:32 pm    Post subject: Reply to topic Reply with quote

For some reason people like to just click on icons. Just use a simple batch file in that case to execute it.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Muskrat
Server Help Squatter


Age:36
Joined: Aug 24 2004
Posts: 829
Location: Swamp
Offline

PostPosted: Thu Nov 16, 2006 10:46 pm    Post subject: Reply to topic Reply with quote

Or he could write programs which either A. don't need input or output in a command line or B. has an input loop that will not end the program until he tells it to.
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Cyan~Fire
I'll count you!
I'll count you!


Age:36
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Fri Nov 17, 2006 12:31 pm    Post subject: Reply to topic Reply with quote

System commands suck. If you really want to wait for an enter key at the end or something, use cin.getc() or whatever it's called. (The getchar() equivalent.) You might want to call cin.flush() beforehand, too, to make sure it has to prompt for input.
_________________
This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Fri Nov 17, 2006 2:07 pm    Post subject: Reply to topic Reply with quote

If you're using MSVC++, do Debug-> Run without Debugging (Ctrl + F5) instead of Debug -> Debug.
_________________
SubSpace Discretion: A Third Generation SubSpace Client
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Non-Subspace Related Coding All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 662 page(s) served in previous 5 minutes.

phpBB Created this page in 0.423886 seconds : 34 queries executed (91.5%): GZIP compression disabled