Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. int main (int argc, char *argv[])
  2. {
  3. FILE *infile;
  4. int pos;
  5. char bigline[1135035] = "";
  6. const char *needle1 = "puid=34561\">";
  7. const char *needle2 = "</a>";
  8. char *start, *end;
  9. int len;
  10. char outline[32];
  11.  
  12. infile = fopen ("test.bin", "r");
  13.  
  14. if (infile == NULL)
  15. {
  16. fprintf (stderr, "Couldn't open file\n");
  17. return 1;
  18. }
  19.  
  20. fgets (bigline, sizeof(bigline), infile);
  21.  
  22. start = bigline;
  23.  
  24. while ( (start = strstr(start, needle1)) != NULL )
  25. {
  26. strcpy (outline, "");
  27. start += strlen(needle1);
  28. end = strstr (start, needle2);
  29. len = end - start;
  30. strncpy (outline, start, len);
  31. outline[len] = '\0';
  32. fprintf (stdout, "%s\n", outline);
  33. start += len;
  34.  
  35. }
  36.  
  37.  
  38. fclose (infile);
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement