mohammed essam
mohammed essam

Reputation: 157

invalid convertion from 'int' to 'const char*'

I'm new to c/c++ and I've been working with python for a long time, I didn't take any tutorials, but I got this error when I tried to declare an array of strings.

code:

    QString months[12]={'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'};

error: invalid conversion from 'int' to 'const char*'

What does that error mean?

Upvotes: 0

Views: 1898

Answers (2)

Amirhossein Mahdinejad
Amirhossein Mahdinejad

Reputation: 574

In the Python is not difference between ' and "(are strings) , but in the C++ They are different:

char   c = 'c';
string str = "string";

Don't forget the C++ has not ''', while it was as string in Python.

Your code:

 ... "Oct", "Nov", "Dec"};

Upvotes: 1

Mat
Mat

Reputation: 206689

Use double quotes for strings ("). ' is for character literals.

Upvotes: 4

Related Questions