Comparing Array's

Hey! If I have a block of text like this:

abcdabcdab5
12345abcdabcdab
23456aaccabcdab
34567aaadabbdab
45678abcdabcdab
56789abcdabcdaa

and want to store the first line of letters in an array and then compare it to the letters next to the ID numbers, how would I go about assigning these characters to their own arrays?

So far I've managed to get the file to read onto the screen but can't get the info into separate arrays.

int main() {
string line;
ifstream myfile ("file.txt");
if (myfile.is_open())
{
while ( getline (myfile,line) )
{
cout<<line<<endl;

}
myfile.close();
}

else cout << "Unable to open file";

return 0;
}
The code below is an example of one way to take a string and make an array out of it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int main() {
	string line = "abcdabcdab";
	char lineArray[10];

	//move string in to array
	for (int count = 0; count < 10; count++) {
		lineArray[count] = line.at(count);
	}

	//output array
	for (int count = 0; count < 10; count++) {
		cout << lineArray[count];
	}
	cout << '\n';

	return 0;
}
Topic archived. No new replies allowed.