ok i have a few questions about this code. it is supposed to display the first name alphabetically and the last name alphabetically from the list.
1. i don't think the strcpy function has been covered yet in the book so i was wondering if there was a different way to assign the current char to the first and last variables.
2. when i used the strcpy function i got a warning saying i should use strcpy_s instead. i have no idea what the difference is could someone explain.
3. when i read in the file it prints to the screen just right but the "last" student is displayed as what i initilized it as which is "aaaaa". how come the name after that alphabetically is not being stored in the "last" variable?
here is my code so far:
using namespace std;
cout << "Corrupt File " << endl;
int numStudents = 0;
char first = "zzzzzz";
char last = "aaaaaaa";
while (infile >> name)
if (strcmp(name,first) < 0)
if (strcmp(name,last) > 0)
cout << name << endl;
cout << "The first student is " << first << endl;
cout << "The last student is " << last << endl;
cout << "There are " << numStudents << " students. " << endl;