Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. //Rodrigo Padres - V00938933 - December 1st, 2019
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5. int main() {
  6. FILE* input_file = fopen("input_text.txt", "r");
  7. FILE* copy_file = fopen("copy.txt", "w");
  8. char ch;
  9. while((ch = fgetc(input_file)) != EOF){
  10. if(isalpha(ch) || ch == '\'' || ch == '-' || ch == '\n'){
  11. fprintf(copy_file,"%c", ch);
  12.  
  13. }else{
  14. ch = ' ';
  15. fprintf(copy_file,"%c", ch);
  16. }
  17. }
  18. fclose(input_file);
  19. fclose(copy_file);
  20. char word[100];
  21. FILE*copy_file_read = fopen("copy.txt", "r");
  22. while(fscanf(copy_file_read, "%s", word) == 1){
  23. printf("Word (%d characters): %s\n",strlen(word), word);
  24. }
  25. fclose(copy_file_read);
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement