Advertisement
rdsedmundo

next id?

Oct 19th, 2014
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.28 KB | None | 0 0
  1. int file_proxid(FILE *arq) {
  2.     CLEAR_ARQ;
  3.  
  4.     int last_id = -1, id = -1;
  5.     char buffer[SIZE];
  6.  
  7.     while (fscanf(arq, "%[^','],%d,%s\n", buffer, &id, buffer) != EOF) {
  8.         if (last_id != (id - 1) && last_id != -1) {
  9.             id = last_id;
  10.             break;
  11.         }
  12.  
  13.         last_id = id;
  14.     }
  15.  
  16.     return ++id;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement