I'm writing a code to put names in alphabetical order. The code i've written wont compile as its teling me that 'left operand needs l value'. The lines it refers to is where i'm trying to swap around strins using pointers. I could use some help with this, thanks!
#include<stdio.h>
#include<string.h>
main(void){
#define CLASS_SIZE 5
#define NAME_LEN 30
char *string[CLASS_SIZE][NAME_LEN];
int i=0;
int j=0;
char *temp;
for(i=0;i<CLASS_SIZE;i++){
printf("Enter a surname, first name and age\n");
gets(string[i]);
}
for(i=0;i<CLASS_SIZE;i++){
puts(string[i]);
}
for(j=0;j<CLASS_SIZE;j++){
for(i=0;i<CLASS_SIZE;i++){
if(strncmp(string[i],string[i+1],30)){
temp=string[i];
string[i]=string[i+1];
string[i+1]=temp;
}
}
}
return 0;
}