Use the iostream library to read in data from the file into a card type and card number. How best to do that will depend on how the information is arranged in the file. A common way to set up a file would be to have two fields per line, separated by spaces or a tab. See example fil contents below.
MasterCard 2222222222222222
Visa 4444444444444444
Discover 3333333333333333
In such a case, you could replace lines 109 to 112 with something like the following...
ins >> ct >> cn;
where ins is an open ifstream object set up to read from an in input file earlier in the program.
ifstream ins;
ins.open("creditcards.txt");
The ins >> ct >> cn; line will read ONE record from the file. You might want to set up a loop where you read continually until there are no more records in the file.
As an aside, you do not use the ct variable anywhere. You read in the credit card type from the user, but then you never do anything with what you read in (the ct variable), but instead set up a card variable and assume the card is a Visa.
VernonDozier
Posting Expert
5,675 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 738
Skill Endorsements: 18