My professor has thrown me a curve ball with this next assignment. The assignment is to make a Monthly Accounting Statement, the program is to you structs and arrays. I get how you can have an array of structs, arrays within a struct, etc...
I have the program mapped out accept for this one part. When I reading in the customer names from the customer.txt file, some of the names have a middle initial, and some dont:
631502 Legg T. 2839 Lionel Ave. +16.30
180003 Hofstra M. 225 Smith Str -6.00
000963 Malioneyh P. J. 4344 Nero Rd +366.92
517724 Morier G. E. 19 Cumberland Ave +60.40
432649 Hauser M. 2940 Toronto Rd 0.00
817387 Currie W. D. 281 Harvard Str +55.00
913478 Hoos R. Dadie 821 County Road -100.00
713422 Smelly Tau 7281 Tobe Cir 0.00
Up until now, all the assignments have had entries similar, with a first and last name only so I just had to read through the file and put things in the appropriate place.
I'm not exactly sure how to go about this. I know it would have to be some kind of check. Do I need to fix the text file and make sure that there are tabs instead of spaces, and then do a check for that? I'm not even sure if my professor would allow me to change the .txt he gives us.
Read the entire line.
Check the characters looking for a letter. That's the beginning of the name and the end of the account number.
Next check looking for a digit. That's the beginning of the address and the end of the name.
The first word in each line appears to be the account number. Everything from the end of the first word up to the first numeric digit can be assumed to be a name. After the name, everything up to either +, -, or a digit is the address.
There's a couple ways to solve the above.
Read the file one character at a line and add the charactrers to the appropriate field in the structure.
Read the entire line at one time then use a pointer to parse the input line.