I have an assignment where you have to ask the user for the names of students. You are then instructed to name the first and last person in the line. I have the code below and after several errors narrowed it down to just one that I can not seem to fix. The error is on line 34 in the if statement that reads : if(studentNames[j]). When I run the compiler it gives me this error code. Could not convert 'studentNames{j}' to bool. Any help would be appreciated thanks
#include <iostream>
#include <cmath> // Allows to ask for input from the keyboard. function cin>>
#include <string> // Allows for string data type
using namespace std;
int main(){
//Variable decleration
string studentNames[25];
string tempName;
int n; //number of students
do
{
cout<<"Enter number of students:";
cin>>n;
}
while(n<0 || n>25);
{
cout<<"Enter the names of the students:";
for(int i=0;i;)
cin>>studentNames[i];
}
int temp;
for(int i=0;i;)
{
temp=i;
for(int j=(i+1);j;)
{
if(studentNames[j])
temp=j;
}
tempName=studentNames[i];
studentNames[i]=studentNames[temp];
studentNames[temp]=tempName;
}
cout<<"Front of line:"<<studentNames[0]<<endl;
cout<<"End of line:"<<studentNames[n-1]<<endl;