0

I am reading from a text file some names and assigning them to arrays. Ex. Mike Smith
John Doe
When reading and assigning to firstName, 'Mike' takes up the first four indicies in the firstName array, but I only want 'Mike' to be in the first index (firstName[0]). Any suggestions?

2
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by Dave Sinkula
0
int acctNumber[MAXCUSTOMERS];
	string firstName[MAXCUSTOMERS];
	string lastName[MAXCUSTOMERS];
	double balance[MAXCUSTOMERS];
inFile >> acctNumber[x] >> firstName[x] >> lastName[x] >> balance[x];

text file:
1000Mike Smith 100.00
1001Stacy Lou 199.00
1002Henry Burris 1000.00
1003Eva McCoy 1999.00
1004John Brown 10000.00

expected output:
acctNumber[0] = 1000
firstName[0] = Mike
lastName[0] = Smith
balance[0] = 100.00

0

Well, if you had posted a minimal code snippet that demonstrates your current output I wouldn't have to ask... What do you see for output?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.