Basically, I'm trying to sort an agenda with 3 names using selection sort method. Pretty sure the selection sort part is OK. The problem is that apparently my code can identify the [0] chars of the string, but cannot pass one string to another variable. Here is my code:
include <stdio.h>
typedef struct{
char name[25];
} NAME;
int main(){
int a, b;
char x, y[25];
static NAME names[]={
{"Zumbazukiba"},
{"Ademiro"},
{"Haroldo Costa"}
};
for(a=0; a<4; a++){
x = names[a].name[0];
y = names[a];
for(b=(a-1); b>=0 && x<(names[b].name[0]); b--){
names[b+1] = names[b];
}
names[b+1].name = y;
}
}
I keep getting this error message:
main.c:21:11: error: assignment to expression with array type y = names[a];
y[a] = names[a]