| | |
Hi
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
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.
) 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.
>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)
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."
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
C++ Syntax (Toggle Plain Text)
#include <iostream.h> int main() { int name; cout << "Hello World!/n"; cout << "Whats your name?: "; cin >> name; cout << "Oh, so your name is " << c; cout << "Thanks for reading, folks..."; return 0; }
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.
>
Change this to
>
Oh, so I suppose that nowadays names consist purely of numbers? If you actually do want to store some letters, try using
>
This is strange... why in the world do you print out 'c' when you just stored the user's name in
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?
#include <iostream.h>Change this to
C++ Syntax (Toggle Plain Text)
#include <iostream> 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."
>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:
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:
C++ Syntax (Toggle Plain Text)
// clear any errors cin.clear(); // flush the input buffer cin.ignore(numeric_limits<streamsize>::max, '\n'); // pause the program cin.get();
"Technological progress is like an axe in the hands of a pathological criminal."
![]() |
Other Threads in the C++ Forum
- Previous Thread: Read data from a two-way array from a .DAT file?
- Next Thread: I need your advice!
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count data database delete deploy developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






