When trying to compile the following code, I am getting a warning that line 18 makes integer from pointer without cast and that 19 and 20 are incompatible types in assignment. I am new to structures in C, and can't seem to figure out what is wrong.
#include <stdio.h>
struct song
{ char title[70];
};
struct playlist
{ struct song songs[100];
};
void title_sort(struct playlist * list,int len)
{ int swapped = 1,i;
char hold;
while (swapped)
{ swapped = 0;
for (i = 0;i < len - 1; i++)
{ if (list->songs[i].title > list->songs[i+1].title)
{ hold = list->songs[i].title;
list->songs[i].title = list->songs[i+1].title;
list->songs[i+1].title = hold;
swapped = 1;
}
}
}
}
int main()
{ struct playlist playlist;
int i;
for (i = 0;i < 5;i++)
{ fgets(playlist.songs[i].title,70,stdin);
}
title_sort(&playlist,5);
printf("\n");
for (i = 0;i < 5;i++)
{ printf("%s",playlist.songs[i].title);
}
return 0;
}