Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. void obrabotka_file(char *fname_i, char *fname_r)
  2. {
  3. FILE *in, *out; //start and result files (streams)
  4. char st[RAZ]; //start string
  5. char sr[RAZ]; //result string
  6. char pr[RAZ]; //handling word
  7. int i, j, k; //number of the handling word
  8. int n; // string's result length
  9. in = fopen(fname_i, PR_R); //open file for reading
  10. out = fopen(fname_r, PR_W); //open file for writing
  11. fgets(st, RAZ, in); //reading string from "in" file
  12. while (!feof(in))
  13. {
  14. i = 0;
  15. n = 0;
  16. sr[i] = '';
  17. while (st[i])
  18. {
  19. k = 0;
  20. while (st[i] == ' ') //deleting spaces in da string
  21. i++;
  22. while (st[i] != ' ' && st[i + 1]) //select another word
  23. {
  24. pr[k] = st[i];
  25. k++;
  26. i++;
  27. }
  28. for (j = 0; j < k; j++, n++)
  29. sr[n] = pr[j];
  30. if (st[i])
  31. sr[n] = ' ';
  32. n++;
  33. i++;
  34. }
  35. sr[n++] = ''; //closing result string
  36. fprintf(out, "%sn", sr); //writing handled string in the new file
  37. fgets(st, RAZ, in); //reading new string from the file
  38. }
  39.  
  40. fclose(in); fclose(out); //Closing "in" abd "out" files
  41. }
  42.  
  43. for (j = 0; j < k; j++, n++)
  44. sr[n] = pr[j];
  45. if (st[i])
  46. sr[n] = ' ';
  47. n++;
  48. i++;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement