C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 17th, 2005, 10:36 PM
BloodlustShaman BloodlustShaman is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: in earth
Posts: 176 BloodlustShaman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 12 h 9 m 3 sec
Reputation Power: 4
Send a message via Yahoo to BloodlustShaman
newbie got a fudgin problem!

this is the code

//---------------------------------------------------------------------------

// my first program in C++

#include <iostream>
using namespace std;

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

and when i run it it opens a new black window with no words but it only opens just for a sec cause then it closes and i have no idea what this mean so yeah some help

Reply With Quote
  #2  
Old July 18th, 2005, 01:25 AM
Geo.Garnett's Avatar
Geo.Garnett Geo.Garnett is offline
Registered Loser
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: Retardation Nation...
Posts: 347 Geo.Garnett User rank is Private First Class (20 - 50 Reputation Level)Geo.Garnett User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 3 h 13 m 45 sec
Reputation Power: 4
Send a message via AIM to Geo.Garnett
Ok this is one newb to another but just try this. Ill leave comments like this // blah blah comments =Þ
Code:
#include <iostream>
using namespace std;

int main (void)//main program code
{
int answer;//answer is just an example, can be anything...
cout<<"Hello World";
cin>>answer;//this will pause the program until a number is entered...
}


you can do this or you can just drop the return 0; before the cin.get() =Þ which ever will work fine, all in how you want to do it though.

Reply With Quote
  #3  
Old July 18th, 2005, 05:25 AM
hacker be hacker be is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 4 hacker be User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 50 m 20 sec
Reputation Power: 0
Talking

Quote:
Originally Posted by BloodlustShaman
this is the code

//---------------------------------------------------------------------------

// my first program in C++

#include <iostream>
using namespace std;

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

and when i run it it opens a new black window with no words but it only opens just for a sec cause then it closes and i have no idea what this mean so yeah some help

I can use code :
#include<iostream.h>
void main()
{
cout<<"HELLO WORLD !"
cin.get();
}

Reply With Quote
  #4  
Old July 18th, 2005, 06:25 PM
BloodlustShaman BloodlustShaman is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: in earth
Posts: 176 BloodlustShaman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 12 h 9 m 3 sec
Reputation Power: 4
Send a message via Yahoo to BloodlustShaman
Wow thanks both u you finally it works with no errors thanks a lot!
I would give u both 20 dollars if u knew u guys

Reply With Quote
  #5  
Old July 18th, 2005, 09:06 PM
Geo.Garnett's Avatar
Geo.Garnett Geo.Garnett is offline
Registered Loser
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: Retardation Nation...
Posts: 347 Geo.Garnett User rank is Private First Class (20 - 50 Reputation Level)Geo.Garnett User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 3 h 13 m 45 sec
Reputation Power: 4
Send a message via AIM to Geo.Garnett
=Þ you can email me it lol

Reply With Quote
  #6  
Old July 18th, 2005, 09:29 PM
ubergeek ubergeek is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2005
Posts: 600 ubergeek User rank is Private First Class (20 - 50 Reputation Level)ubergeek User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 40 m 27 sec
Reputation Power: 4
Send a message via AIM to ubergeek
you still need a return 0; after the cin.get()

Reply With Quote
  #7  
Old July 19th, 2005, 04:00 AM
B-Con's Avatar
B-Con B-Con is offline
:bcon: moderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Location: int main()
Posts: 351 B-Con User rank is Private First Class (20 - 50 Reputation Level)B-Con User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 23 h 8 m 6 sec
Reputation Power: 4
Quote:
cout << "Hello World!";
return 0;
cin.get();

Look at the order of your code. You have "cout" followed by "return" followed by "cin.get".

First, it will print text to the screen, then the function will end, then it will be paused to wait for input.

But your problem is, you're already exited the function before the pause command. Switch the order of "return" and "cin.get"
__________________
Officially a member of the Itsacon fan club. Beer blasts are every friday at Viper_SB's house. I bring the chips.



Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > newbie got a fudgin problem!


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT