Zia ur Rahman
Zia ur Rahman

Reputation: 1431

Inputting a string

i want to store a string entered by the user including the space characters into the following array

char array[100];

how can i do it.

Upvotes: 0

Views: 356

Answers (3)

Anne
Anne

Reputation: 480

Documentation for getline can be found here: http://cplusplus.com/reference/iostream/istream/getline/

Upvotes: 0

Sani Huttunen
Sani Huttunen

Reputation: 24395

cin.getline(array, 100, '\n');

Upvotes: 2

frbry
frbry

Reputation: 499

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);

Upvotes: 3

Related Questions