while((c = getc(file)) != -1) { if (c == ';') { //here want skip line starts ; //i don't want read more characters on line } else { { //here stuff }while (c != -1 && c != '\n');//until end of file } } can skip line using getc if first character of line semicolon?
your code contains couple of references -1. suspect you're assuming eof -1. that's common value, required negative value — negative value fit in int. not bad habits @ start of career. write eof checking eof (and don't write eof checking -1).
int c; while ((c = getc(file)) != eof) { if (c == ';') { // gobble rest of line, or until eof while ((c = getc(file)) != eof && c != '\n') ; } else { { //here stuff … } while ((c = getc(file)) != eof && c != '\n'); } } note getc() returns int c declared int.
Comments
Post a Comment