for(int i=0;i<NoCand;i++)
{for(int j=i+1;j<NoCand;j++)
{
if(NumVotes[j]>NumVotes[i]) {
char temp_LastName = LastName[i];
float temp_NumVotes = NumVotes[i];
LastName[i] = LastName[j];
NumVotes[i] = NumVotes[j];
LastName[j] = temp_LastName;
NumVotes[j] = temp_NumVotes;
}
}
I'm attempting to use this algorithm to rearrange my character array so that it's in order with my NumVotes value. However it will not allow me to assign the char to char.
I know this works with strings but for the purpose of this I'm not allowed to use strings.
I am guessing that your LastName array is an array of strings. Is it?
In that case you should declare temp_LastName as char*.
Edit: sorry above will not work because you cannot sssign char arrays like pointers. You will probably have to swap using function like strcpy () or some other function to manipulate c strings. I'm not much conversant with them.