Apr 5, 2011 at 2:51am UTC
I have a question,
I need to know if it is possible to do a switch case using a string
What I did is the following:
string *item_name = x.substr(i,x.size()-1);
item_names = new char [item_name.size() +1];
item_names[item_name.size()] = 0;
memcpy(item_names, item_name.c_str(), item_name.size());
It gives me an error in the case
ERROR: too many characters in character constant
What it could be?
Last edited on Apr 12, 2011 at 5:41am UTC
Apr 5, 2011 at 3:08am UTC
You can only use switch with integral types, so that won't work.
And string literals are enclosed with double quotes. Single quotes are for single characters.