FILE *f; char buf[128],*s=NULL; f=fopen("filename","rb"); while (!fgets(f,127,buf)){ s=strtok(buf,"\r\n"); while (s){ s=strtok(NULL,"\r\n"); //got line part starting with s } }