Mike_King

Untitled

Oct 2nd, 2012
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <stdio.h>
  2. int main(int argc, char *argv[])
  3. {
  4. FILE * fi;
  5. fi = fopen("test.txt","rt");
  6.  
  7. int a[100];
  8. int i, size;
  9.  
  10. while (fscanf(fi, "%d", &size) == 1)
  11. {
  12. for (i = 0; i < size; ++i)
  13. {
  14. if (fscanf(fi, "%d", &a[i]) != 1)
  15. {
  16. perror("Error occurred: ");
  17. exit(1);
  18. }
  19. }
  20. }
  21. fclose(fi);
  22.  
  23. printf("%d %d %d", a[0], a[1], a[2]);
  24.  
  25. getch();
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment