I have made some adjustments now it seems to be running better its giving me the
ID: 3532866 • Letter: I
Question
I have made some adjustments now it seems to be running better its giving me the last student but not the first student in its place is a smiley face. Please help I will rate you a 5 if your input helps.
int main()
{
ifstream inputFile;
int students;
int count;
char names[25];
char first[25];
char last[25];
inputFile.open("F:\LineUp.txt");
cout << "Enter in the number of students in the class: ";
cin >> students;
cin.ignore(25,' ');
while (students < 1 || students > 25)
{
cout << "Enter in a number that is no less than 1 and no more than 25: ";
cin >> students;
}
for (int count = 0; count <= students; count++)
{
inputFile >> names;
count++;
if (students == 0)
{
strcpy(first, names);
strcpy(last, names);
}
if (strcmp(names,first) < 0)
{
strcpy(first, names);
}
if (strcmp(names,last) > 0)
{
strcpy(last, names);
}
}
cout << "The first student is " << first << endl;
cout << "The last student is " << last << endl;
inputFile.close();
system("PAUSE");
return 0;
}
Explanation / Answer
here you go:
http://ideone.com/PHi1l7