URGENTTT HELP IN C++ ERROR: too many characters in character constant

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
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.
Topic archived. No new replies allowed.