Author | Message | Time |
---|---|---|
Mitosis | Ok I copied exactly out of my book but I keep getting compiler errors.This is what I got. #include <iostream> #include <stdlib.h> #include <string> using namespace std; int main(int argc, char *argv[]) { string mystring; mystring = "hello there" endl; cout << mystring << endl; system("PAUSE"); return 0; } It keeps saying mystring = "hello there" endl; is wrong. But its exactly out of the book. Any help would be aprecaited. | January 9, 2004, 11:44 AM |
mejal | [quote author=Mitosis link=board=30;threadid=4657;start=0#msg38969 date=1073648668] mystring = "hello there" endl; [/quote] Probably a misprint. Delete endl on this line. | January 9, 2004, 12:12 PM |
Mitosis | Thanks Mejal. It worked. Weird though, in my book C++ for dummies it always tells me to have endl at the end just before the ;. Ohwell thanks for your help. | January 9, 2004, 12:43 PM |
iago | To put more than one parameter on a cout line, they have to be seperated by <<'s. So on that line, put << between "hello there" and end. | January 9, 2004, 12:59 PM |
Skywing | [quote author=Mitosis link=board=30;threadid=4657;start=0#msg38972 date=1073652198] Thanks Mejal. It worked. Weird though, in my book C++ for dummies it always tells me to have endl at the end just before the ;. Ohwell thanks for your help. [/quote] endl is only used in conjunction with cout, cerr, or other ostream objects. | January 9, 2004, 6:00 PM |
iago | Actually, Skywing's right, I didn't really need that code. You only want to have endl on lines with cout and similar operators, not in string or anything like that. | January 9, 2004, 7:04 PM |