bhupixb

File handling in C without Spaces

Oct 3rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. char s[100], arr[100];
  4. #define f fflush(stdin)
  5. int main(){
  6. int n;
  7. scanf("%d", &n);
  8. f;
  9.  
  10. FILE *fp;
  11.  
  12. fp = fopen("my.txt", "w");
  13. while(n--){
  14. f;
  15. scanf("%s", s);
  16. fprintf(fp, "%s %c", s, '\n');
  17. }
  18. fclose(fp);
  19.  
  20. fp = fopen("my.txt", "r");
  21. while(fscanf(fp, "%s", arr) != EOF){
  22. f;
  23. printf("%s\n", arr);
  24. }
  25. fclose(fp);
  26. return 0;
  27. }
Add Comment
Please, Sign In to add comment