开发者

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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜