tags:

views:

133

answers:

4

with char i get this error: .\main.cpp(6) : error C2015: too many characters in constant

+6  A: 

A char only holds one character:

char bar = 'a';

If you want more, use a string constant to initialize a character array:

char foo[] = "This is my thing";
jeffamaphone
+1  A: 

Use a string i.e. array of characters For example char s[] = "Hello";

Naveen
Or, if you're not planning on modifying the string, a `char *s = "Hello";` will do.
Eclipse
That uses a deprecated conversion in C++ though, use `const char* s = "Hello";` or preferably `std::string`.
Mark B
In fact, in C++0x the conversion is not allowed anymore.
Johannes Schaub - litb
+6  A: 

Given the file extension cpp, I am going to go out on a limb and assume you are using C++. If so, use the string class to store a string.

Sinan Ünür
+2  A: 

See Compiler Error C2015 for an explanation of the error. MSDN is a great source of knowledge and usually describes the error messages from Visual Studio (as I assume you are using) in more detail.

Martin