The type of the string literal in C++ is char const[6]
, and char[6]
in C (it's the number of characters in the literal, including the terminating NUL character).
While char *b = "hello";
is legal in C, it is deprecated in C++03, and illegal in C++11. You must write char const *b = "hello";
The reason that works is because both languages define an implicit conversion of array types to a pointer to the first element of the array. This is commonly referred to as decay of the array.
No such conversion is applicable to int *a = 10;
, so that fails in both languages.