I am trying to perform bubble sort on a memory that contains a certain amount of structures of the same type.I am a little bit confused with the pointer logic.
For e.g i have a list with 12 offices.
Code:
void sortList(struct child *p,int noofchildren){
struct man *out;
struct man *in;
struct man *temp;
for(out= 12 * sizeof(struct man);out>1;out--){
for(in=p;in<out;in++){
if(strcmp(p->name,p->name+1)==1){
temp=p;
p=p+1;
(*p)+1=temp;
}
else
if(strcmp(p->name,p->name+1)==1){
if(p->age>p->age+1){
temp=p;
p=p+1;
*(p)+1=temp;
}
}
}
}
}