Inputting a string
i want to store a string entered by the user includi开发者_运维知识库ng the space characters into the following array
char array[100];
how can i do it.
You can use the following to get the user-entered string to a string object, then convert it to whatever you need:
string c;
getline(cin, c);
cin.getline(array, 100, '\n');
Documentation for getline can be found here: http://cplusplus.com/reference/iostream/istream/getline/
精彩评论