// m3u to tracklist.txt // I rip cd's and i create .m3u files that usually look like // #EXTM3u // #EXTsomething blahblahbalh // 01 - artist - track // #EXTsomething blablabalbla // // so I wrote this application to read the .m3u, create a .tracklist.txt // and only copy over the lines not starting with # #include int main() { int c,lineskilled,n; //c is the getchar() checker //i is the amount of lines deleted counter //n is the '\n' counter(used to show what line number has been deleted) FILE *fp; int countgoodlines; fp = fopen("tracklist.txt","w"); //file tracklist.txt should not exist c = lineskilled = n = countgoodlines = 0; while((c = getchar()) != EOF) { if(c == '#') { printf("Line %d has been deleted\n",n++); ++lineskilled; for( ; ; c=getchar()) if(c == '\n') break; } else if(c != '#') { //here I copy over the good lines for(;;c=getchar()) { if(c != '\n') fprintf(fp,"%c",c); else break; } fprintf(fp,"\n"); } } //display the amount lines that were not written to the new file (tracklist.txt) printf("%d lines have been deleted.\n",lineskilled); fclose(fp); return 0; }