Hi

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2007
Posts: 8
Reputation: MadsenAim3r is an unknown quantity at this point 
Solved Threads: 0
MadsenAim3r's Avatar
MadsenAim3r MadsenAim3r is offline Offline
Newbie Poster

Hi

 
0
  #1
Apr 19th, 2007
Hi, this is Chris, and I was hoping that you guys could supply me with the code (yah, I know that you guys don't do homework, but this is an exception? ) for making a simple "Hello World" program? Even one that asks answers of the user (for example, "Whats your name?" then, with cin I use it later? I can do this, but my book is totally out-dated, so I can't use it on the C++ program I have now (Dev-C++)).
In advance, thanks guys.
Nothing witty to say.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Hi

 
0
  #2
Apr 19th, 2007
>I was hoping that you guys could supply me with the code
We can, but that doesn't mean we will.

>I know that you guys don't do homework, but this is an exception?
Nope.

>I can do this, but my book is totally out-dated
Get a new one. Or use one of the many-available online tutorials, such as this one.

Or you could just give us the code that's "outdated", and we'll tell you what's wrong with it. (most likely it's using iostream.h instead of iostream, or worse, using void main instead of int main)
"Technological progress is like an axe in the hands of a pathological criminal."
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 8
Reputation: MadsenAim3r is an unknown quantity at this point 
Solved Threads: 0
MadsenAim3r's Avatar
MadsenAim3r MadsenAim3r is offline Offline
Newbie Poster

Re: Hi

 
0
  #3
Apr 19th, 2007
alright. heres the code, I will do some tutorials now, and . . . Book? Sometime, maybe... Not sure how into C++ i am, it's just a hobby. We'll see
  1. #include <iostream.h>
  2.  
  3. int main()
  4. {
  5. int name;
  6. cout << "Hello World!/n";
  7. cout << "Whats your name?: ";
  8. cin >> name;
  9. cout << "Oh, so your name is " << c;
  10. cout << "Thanks for reading, folks...";
  11. return 0;
  12. }
Last edited by ~s.o.s~; Apr 19th, 2007 at 11:23 pm. Reason: Fixed code tags, learn to use them.
Nothing witty to say.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Hi

 
0
  #4
Apr 19th, 2007
>#include <iostream.h>

Change this to
  1. #include <iostream>
  2. using namespace std;

>int name;

Oh, so I suppose that nowadays names consist purely of numbers? If you actually do want to store some letters, try using string instead, but you might have to include <string>.

>cout << "Oh, so your name is " << c;

This is strange... why in the world do you print out 'c' when you just stored the user's name in name??

And the list carries on... did you write that yourself, or did you get that from somewhere? Why not just work your way through cprogramming's tutorials until you're fairly comfortable with the C++ programming language?
Last edited by John A; Apr 19th, 2007 at 11:41 pm.
"Technological progress is like an axe in the hands of a pathological criminal."
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 8
Reputation: MadsenAim3r is an unknown quantity at this point 
Solved Threads: 0
MadsenAim3r's Avatar
MadsenAim3r MadsenAim3r is offline Offline
Newbie Poster

Re: Hi

 
0
  #5
Apr 19th, 2007
well, for the 'c' thing, I had it as 'c' in the first place, wrote the code, then was like "C is confusing, may as well make it name"
true, the thing has changed (or always was) string.
cool. and also the header thing, got that down too now. Thanks!
Nothing witty to say.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 8
Reputation: MadsenAim3r is an unknown quantity at this point 
Solved Threads: 0
MadsenAim3r's Avatar
MadsenAim3r MadsenAim3r is offline Offline
Newbie Poster

Re: Hi

 
0
  #6
Apr 19th, 2007
I have one final problem, although it might have been related to the things that I've changed above. I dont have my C++ on this computer right now. When I ask a question that (after this) gets 'cin'ned, the window shuts down after you type enter. Why?
Nothing witty to say.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Hi

 
0
  #7
Apr 20th, 2007
>When I ask a question that (after this) gets 'cin'ned, the window shuts down after you type enter.
Basically Windows closes console applications when the execution is finished. You can fix this problem by pausing the application before it closes by using something like this:

  1. // clear any errors
  2. cin.clear();
  3.  
  4. // flush the input buffer
  5. cin.ignore(numeric_limits<streamsize>::max, '\n');
  6.  
  7. // pause the program
  8. cin.get();
"Technological progress is like an axe in the hands of a pathological criminal."
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC