I'm making this student record program that my prof asked us to do. It keeps saying cannot convert 'StudRec' to 'StudRec' in assignment and sometimes it says cannot convert char* to const char*. StudRec is my struct variable and this is the function that should sort the recorded names alphabetically.
void sort_name(StudRec name[], StudRec temp[], int studcount)
{
if (studcount > 0)
{
for (int i=0; i<studcount; i++)
{
for (int j=studcount; j<=i; j++)
{
if(strcmp(name[j].nm, name[j+1].nm) > 0)
{
temp=name[j];
name[j]= name[j+1];
name[j+1]= temp;
}
}
}
cout << "\t| |\t\t\t The records have been sorted alphabetically by name.\n";
}
else
{
cout << "\t| |\t\t\t There is no current record to sort by name.\n\n";
}
}
StudRec, the actual compiler error, and the caller code. anyway, even if that would compile, your inner loop would always be skipped becausejis always greater thani.jwill always be more thani, since you're initializing it atstudcount, whichiwill never reach. I'm assuming you want that to beint j = studcount; j>i; j--. Second, show StudRec and which line the errors are happening on.