Simple C++ question
|
Original Message
|
Name: Emmalee
Date: September 9, 2002 at 07:28:35 Pacific
Subject: Simple C++ question OS: Win 98 CPU/Ram: Pentium II 450
|
Comment: I am writing a simple program for my C++ class we have to display personal info on the screen. Name on one line address on another and so on. Well you can only use one cout statement. I need some help.
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: Don Arnett
Date: September 9, 2002 at 08:38:58 Pacific
Subject: Simple C++ question |
Reply: (edit) I'm a C programmer who learned C++ second, so I don't use 'cout', but the idea is that you need to output a newline between each bit of information. In C you'd use '\n' to output a newline character. I'm sure that this would work in C++, but I think that the 'official' C++ way is to use 'endl'.
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: Nirav
Date: September 9, 2002 at 12:34:39 Pacific
Subject: Simple C++ question
|
Reply: (edit)cout << " Address: " << address << endl << "Name " << name << endl;
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: Jeff J
Date: September 9, 2002 at 23:36:01 Pacific
Subject: Simple C++ question |
Reply: (edit)Formally, endl is '\n' along with an immediate buffer flush. So it can be used like a newline, though there's no need to use it in between inserter operators. I must admit I'm still adjusting to C++ I/O, and finding clear documentation always seems like pulling teeth.
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: ANG
Date: September 12, 2002 at 16:52:06 Pacific
Subject: Simple C++ question
|
Reply: (edit)cout << "name" << "addres" << endl << "phone number" << endl;
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: