I. Source of the problem
Today on the VS2010 platform, try using scanf ()
string Word;
scanf ("%s", &word);
Then the error is found and the output takes
printf ("%s\t", word);
Found also not, then converted to CIN and cout OK, so suspect is not%s out of the question, sure enough.
Because a string in C is stored in a char array, it is a combination of basic types, but string is a encapsulated class in C + +.
So the output can be used
printf ("%s\t", Word.c_str ());
But the sense of input is not saved Ah!
2. Online answer (from Baidu know)
It is not always clear to this question: just know that C language has <string.h this header file, so it is assumed that C language has string this
Type, you can declare a string of variable string astring by this form;
Later when the program found that the compilation, but also check the data to know that the original C language there is no string this type, so the string is stored through a char array,
The function prototype declared in <string.h's header file is all about the various operations of the char array. The string class was not present until C + + (note the class,
Not a type). This is the more satisfactory answer I found on the Internet:
"Is there a string type variable in the C language?"
The string here has two semantics.
(1) If string is a generic word, "C language has a character type variable", answer, yes. The character type is declared with Char.
Char str[]= "This is a string";
(2) If string is a special term, "C language has a string type variable", a, No. A string is a class, is a classes, not a type.
Is there a string type in C language?