names will not switch using bubble sort

Im trying to rank a class from least to greatest by average, but Im trying to switch the names along with them, but the names do not switch. Can someone help me out? Here is part of my code:

int i=0, j=0,test=0,n=20;
float tmp;
char tmp2[20];


for (i=0; i<n-1; i++) {
for (j=0; j<n-1-i; j++){
if (average2[j+1] < average2[j]) { /*****compare the two numbers ******/
tmp = average2[j]; /*****swap average2[j] and average2[j+1]******/
tmp2[j]=names_array[j][0];

average2[j] = average2[j+1];
names_array[j][0]=names_array[j+1][0];

average2[j+1] = tmp;
names_array[j+1][0]=tmp2[j];
}
}
}

you cant directly assign an array to another array, you need to go char by char with a loop
yea it works with numbers but i dont see why it cant work with strings. So i have to do it letter by letter?
Topic archived. No new replies allowed.