Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <stdio.h>
- #include<string.h>
- #include<locale.h>
- #include <stdlib.h>
- FILE *fd;
- int main()
- {
- setlocale(LC_ALL, "polish");
- system("chcp 1250");
- char k, l, pom;
- int i = 0;
- if (!(fd = fopen("tekst1.txt", "r")))
- {
- printf("Błąd wczytwania tekstu 1\n");
- exit(5);
- }
- printf("\nTekst \n"); // Wypisywanie tekstu 1
- while (fscanf(fd, "%c", &k) != EOF)
- {
- printf("%c", k);
- }
- printf("\n");
- fclose(fd);
- fd = fopen("tekst1.txt", "r");
- while (fscanf(fd, "%c", &k) != EOF ) // Szukanie wyrazów
- {
- fscanf(fd, "%c", &l);
- if (l == EOF && k != ' ')
- {
- i++;
- break;
- }
- if (k != ' ' && l == ' ')
- {
- i++;
- }
- if (k == ' ' && l != ' ')
- {
- i++;
- }
- }
- printf("Ilość wyrazów w tekscie to %d \n", i);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement