How to read in strings into multiple arrays

So i have 2 string types 1 for last names and 1 for first names and i also have an int type for ages and the user input would be a full sentence and it would look like this: First Last Age
and i need to separate first name last name and age into separate arrays so how do i do that ?
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include<iostream>
#include<string>
using namespace std;

int main()
{
	string first_name[100] , second_name[100];
	int age[100];
	
	char x;
	
	for(int i=0;i<100;i++)
	{
		cout<<"Enter first name, second name, and age"<<endl;
		cin>>first_name[i]>>second_name[i]>>age[i];
		
		cout<<"do you wish to add more entry? (y/n)";
		cin>>x;
		
		if(x=='n' || x=='N')
		break;
	}
	
	return 0;
}


does it look like what you want? i set array size to 100 assuming that user wouldn't input more than 100 entries..
Yes that's what i needed thank you!
Topic archived. No new replies allowed.