please help.. beginner cout problem c++

dear people,
I just started with learning C++
I hope you can help me with this issue.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  #include <iostream>;
using namespace std;
         
int main() {
int age;

cout<<"give your age: ";
cin>> age;
cin.ignore();
if (age < 30 ){
cout<<"very young! :) \n";
}
else if ( age > 40 ) {
     cout<<"ya getting old... n\";
}
else {
cout<<" mid-age friend! (: n\";
}
cin.get();
}
 


DEV++ gives this line an error

Line 14
 
     cout<<"ya getting old... n\"; 


what do i do wrong?

Thanks!!
Last edited on
On your line 14 and line 17 check the n\";
well you see, the "\" is used as an escape character. Let's say you have a string like this:
string name = "Have you read "Ghost in the shell" manga?";
the second " will just end the string.
For the " to be acetable between other " " you need to escape them.
A corect way would be this.
string text = "Have you read \"Ghost in the shell\" manga?";
In essence you are escaping the closing ";
Just move the \ before the n and your problem should be solved.
Also, what IDE(Integrated development enviroment) are you using? The compiler from that ide should warn you about that.
thanks alot,

DevC++ did just say that there was a missing character....

finally I can proceed the next step!

Topic archived. No new replies allowed.