What did I do wrong?

I am learning c++ from a book I found at the library (I have been wanted to learn for years but have been too lazy) and Ive been doing fine.
but now I made it to this code
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
using std::cin;
using std::cout;
int main()
{
    char text[10];
    cout << "Please enter a word\n";
    cin.getline(text,10);
    cout << text << end1;
    reutrn 0;
}


and It (my compiler) says there is a error on line with "cout << text << end1;
Any ideas what I did wrong?
cout << text << endl;
it's endl not end1 (it's ends in the letter L, not the number 1)

Also.. endl is in the std namespace, so you'll have to say using std::endl; or you'll have to do cout << text << std::endl;


Lastly... the book probably shouldn't be starting you off with char arrays. I'd recommend starting with std::string for strings. They're much more intuitive and less errorprone. But whatever. char arrays will work as long as you're careful.
IMO starting with char arrays is not that bad, you understand strings better if you know char array.. that's just my opinion..
Its just starting off, but thanks for the help disch, that clears it all up for me.. Thats what having bad eye sight does for you xD.. I have 3 books so I might switch over to the other one.. Or Ill stick with this one and just learn as I go.. THanks again guys. Big help
IMO starting with char arrays is not that bad, you understand strings better if you know char array.. that's just my opinion..


IMO, It's biting off more than you can chew.

Yes, learning about char arrays is useful, I won't deny that. But when you're just starting out with the language you already have enough on your plate. There's so many other rules to learn that the important details of char arrays, char pointers, string copying, etc cannot all be fully understood without getting you all confused.

It's like learning to drive. It's better to start with an automatic to learn the rules of the road, then you learn how drive stick. Starting off with stick is waaaay harder.
There's so many other rules to learn that the important details of char arrays, char pointers, string copying, etc cannot all be fully understood without getting you all confused.

i agree with that.. though if i were a teacher, i'd still teach char arrays first before strings..

It's like learning to drive. It's better to start with an automatic to learn the rules of the road, then you learn how drive stick. Starting off with stick is waaaay harder.

i don't know how to drive since i dont have a car, but most people can learn it anyway.. if it were in programming i still prefer to drive in stick first.. then auto would be much easier later..


just like strings and automatic cars are at higher level and easier manipulation that char arrays and manual cars, i believe it's harder to dig what's going on below.. i prefer to start at the bottom and slowly go up..


just to make it clear, i respect your suggestion.. also every person learn better in different ways..
Topic archived. No new replies allowed.