The following script was posted as a solution to a problem I did in school, however, when I run this exact script I get 3 warnings and the script will not complete. I have also attached the warnings. They are below the script. Any help is greatly appreciated.
#include <iostream>
#include <cstdlib>
using namespace std;
struct FullName
{
char first[30];
char last[30];
};
struct StudentData
{
FullName name;
char nid[30];
int score;
};
bool GetString(char []);
bool GetNID(char []);
bool GetScore(int *);
void DisplayStudent(StudentData);
void main()
{
StudentData student[100];
int n,i;
float aveSco = 0.0;
char space = ' ';
bool valid;
int score;
do
{
cout << "Enter the number of students (0-100): ";
valid = GetScore(&n);
if (!valid)
{
cout << "Invalid Entry... Try again\n";
}
} while (!valid);
for (i=0;i<n;i++)
{
cout << "\nStudent #" << i+1 << endl;
do
{
cout << "Enter the first name of student #" << i+1 << ": ";
valid = GetString(student[i].name.first);
if (!valid)
{
cout << "Invalid Entry... Try again\n";
}
} while (!valid);
do
{
cout << "Enter the last name of student #" << i+1 << ": ";
valid = GetString(student[i].name.last);
if (!valid)
{
cout << "Invalid Entry... Try again\n";
}
} while (!valid);
do
{
cout << "Enter the NID of student #" << i+1 << ": ";
valid = GetNID(student[i].nid);
if (!valid)
{
cout << "Invalid Entry... Try again\n";
}
} while (!valid);
do
{
cout << "Enter the score of student #" << i+1 << " (0-100): ";
valid = GetScore(&student[i].score);
if (!valid)
{
cout << "Invalid Entry... Try again\n";
}
} while (!valid);
}
cout << endl << endl;
do
{
cout << "Enter the curve score (0-100): ";
valid = GetScore(&score);
if (!valid)
{
cout << "Invalid Entry... Try again\n";
}
} while (!valid);
for (i=0;i<n;i++)
{
if (student[i].score < score)
{
DisplayStudent(student[i]);
}
}
}
bool GetString(char string[])
{
int i;
bool validString = true;
cin.getline(string,30);
i=0;
do
{
if (((string[i] < 'A') || (string[i] > 'Z')) &&
((string[i] < 'a') || (string[i] > 'z')))
{
validString = false;
}
i++;
} while ((validString) && (i < strlen(string)));
return validString;
}
bool GetNID(char string[])
{
int i;
bool validString = true;
cin.getline(string,30);
i=0;
do
{
if (((string[i] < '0') || (string[i] > '9')) &&
((string[i] < 'a') || (string[i] > 'z')))
{
validString = false;
}
i++;
} while ((validString) && (i < strlen(string)));
return validString;
}
bool GetScore(int *score)
{
int i;
char string[30];
bool validString = true;
cin.getline(string,30);
i=0;
do
{
if ((string[i] < '0') || (string[i] > '9'))
{
validString = false;
}
i++;
} while ((validString) && (i < strlen(string)));
if (validString)
{
*score = atoi(string);
if ((*score) > 100)
{
validString = false;
}
}
return validString;
}
void DisplayStudent(StudentData entry)
{
cout << entry.name.first << " ";
cout << entry.name.last << " NID: ";
cout << entry.nid << " Score is: ";
cout << entry.score << endl;
}
1>------ Build started: Project: assignment10, Configuration: Debug Win32 ------
1>Compiling...
1>file1.cpp
1>c:\users\cvarner\desktop\assignment10\assignment10\file1.cpp(124) : warning
C4018: '<' : signed/unsigned mismatch
1>c:\users\cvarner\desktop\assignment10\assignment10\file1.cpp(144) : warning
C4018: '<' : signed/unsigned mismatch
1>c:\users\cvarner\desktop\assignment10\assignment10\file1.cpp(164) : warning
C4018: '<' : signed/unsigned mismatch
1>Linking...
1>Embedding manifest...
1>Build log was saved at "file://c:\Users\cvarner\Desktop\assignment10\assignment10
\Debug\BuildLog.htm"
1>assignment10 - 0 error(s), 3 warning(s)