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.
Quote from: Mitosis on January 09, 2004, 05:44 AM
mystring = "hello there" endl;
Probably a misprint. Delete endl on this line.
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.
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.
Quote from: Mitosis on January 09, 2004, 06:43 AM
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.
endl is only used in conjunction with
cout,
cerr, or other
ostream objects.
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.