Taking in multiple user inputs at once

Hi everyone, I'm not sure how simple this is but I'm having a hard time figuring it out. I'm building a sort of user file system and I need to take in commands from a user. For example they could type something like "logout" or "mkdir directory1"

Unfortunately I'm not sure about how to take in an unknown amount of inputs. I vaguely remember there being a way to cin everything into an array? that would be ideal...

Thanks

-Dan
you can use getline(cin, var) or you can use getline(cin, var, until). The second option there is telling it to continue passing characters into a string array until it runs into whatever character you set my until variable to equal, or until the end of the line of course.
Here's an example of what I mean;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

#include <iostream>
using namespace std;



int main()
{
string bacon, eggs;
cout<<"write a sentence about bacon"<<endl;
getline(cin,bacon);
cout<<"now write a sentence about eggs with an exclamation point somewhere in the middle of it"<<endl;
getline(cin,eggs,'!');

cout<<bacon[0]<<bacon[1]<<bacon[2]<<bacon[3]<<endl;
cout<<bacon<<endl;
cout<<eggs<<endl;

return 0;

}
Topic archived. No new replies allowed.