This program is supposed to grab an answer key from the first line of a file. I have to use c-strings for the assignment which is very annoying. I thought I had it but the function only put the letter F in the output file. This is what a example input file would look like :
ACDBCBDCCACDACC
George Washington abcdabcdabcdccc
John Adams abaa aaccacdacc
The top line is the answer key and the rest is supposed to be used to check if the students got answers wrong/right.
Here is my code so far:
The function get_key is supposed to get the first line and store it in the c-string char key[50] but it is not returning correctly. I got it to return the last for letters of the line but that is the closest I have got. Thanks for any help.
You can search through the string to find spaces, and copy out string data that way.
If the file format is fixed, you can inf.getline() with a space as delimiter for the first name, last name, etc, and just inf.getline() without any explicit delimiter (newline) for the final item on the line.