Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void skipspaces(FILE* f)
- {
- if (!f) return;
- rewind(f);
- fpos_t start, end, mainstart;
- char s;
- int count;
- while (!feof(f))
- {
- count = 0;
- while ((s = fgetc(f)) && s != ' ' && !feof(f) && s != '\n');
- if (feof(f)) return;
- fgetpos(f, &mainstart);
- start = mainstart;
- while ((s = fgetc(f)) && s == ' ' && !feof(f)/* || s == '\n'*/) count++;
- if (feof(f)) return;
- fseek(f, -1, SEEK_CUR);
- fgetpos(f, &end);
- if (count > 0)
- {
- while (!feof(f))
- {
- fsetpos(f, &end);
- s = fgetc(f);
- if (s == EOF) break;
- fsetpos(f, &start);
- fputc(s, f);
- start++; end++;
- }
- fsetpos(f, &mainstart);
- }
- }
- }
Add Comment
Please, Sign In to add comment