Advertisement
Guest User

Untitled

a guest
Feb 26th, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. //Program that modifies a binary file of a fuck tonne of numbers
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #define SIZE 1000
  5.  
  6. main()
  7. {
  8. FILE *fp;
  9. int numArray[SIZE]={0};
  10. int zero[1]={0};
  11. int i;
  12.  
  13. fp=fopen("num1000.bin","r+b");
  14.  
  15. fseek (fp,2*sizeof(int),SEEK_SET);
  16. fwrite (zero,sizeof(int),1,fp);
  17. fseek (fp,9*sizeof(int),SEEK_SET);
  18. fwrite (zero,sizeof(int),1,fp);
  19.  
  20. rewind(fp);
  21.  
  22. fread(numArray,4,SIZE,fp);
  23.  
  24. for (i=0;i<SIZE;i++)
  25. {
  26. printf("%d ",numArray[i]);
  27. }
  28.  
  29. fclose(fp);
  30. getchar();
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement