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, *c;
- int j = 0, o = 0, p = 0;
- if (!(fd = fopen("tekst.txt", "r")))
- {
- printf("Błąd wczytwania tekstu 1\n");
- exit(5);
- }
- while (fscanf(fd, "%c", &k) !=EOF)
- {
- j++;
- }
- for (int i = 0; i <= j;i++)
- {
- c= malloc(j * sizeof(char));
- }
- fclose(fd);
- fd = fopen("tekst1.txt", "r");
- while (fscanf(fd, "%c", &k) != EOF)
- {
- c[o] = k;
- o++;
- }
- for (int i = 0; i < j; i++)
- {
- printf("%c", c[i]);
- }
- printf("\n");
- for (int i = 1; i < j; i++)
- {
- if (c[i - 1] != ' ' && c[i] == ' ')
- {
- p++;
- }
- }
- if(c[j-1]!=' ')
- {
- p++;
- }
- printf("Ilość wyrazów w tekscie to %d \n", p);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement