strings and if's

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

int main()
{
    string mystring;
    cout<<" Enter your name: ";
    getline (cin,mystring);
    if (mystring == 'vlad'){
        cout<<" Hi vlad....weve been waiting for you...";
    }
    else {
        cout<<" Hello, "<<mystring<<" how are you today?";
    }


cin.get();
return 0;

}


i seem to be having an error in my if (mystring == 'vlad'

at first i tried withought the ' ' then put those on just incase, not too sure about what else to change
You must use double quotes for strings "vlad"
lol thanks you....i hate these little knickers about programming....just deal with them and learn i guess right?
closed account (jwC5fSEw)
There's actually a pretty good reason for it; double quotes designates a null-terminated string literal (i.e. any string), whereas single quotes are used for individual characters.
Last edited on
Topic archived. No new replies allowed.