Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- int main(int argc, char * argv[]) {
- if(argc < 2) {
- printf("Ne vnesovte vlezna datoteka\n");
- return 0;
- }
- FILE * in = fopen(argv[1], "r");
- if(in == NULL) {
- printf("Datotekata ne postoi\n");
- return 0;
- }
- char c;
- char niza[2000];
- int i = 0;
- int brojac = 0;
- while((c = fgetc(in)) != EOF) {
- if(c == '!' || c == ',') {
- if(i >= 5) {
- for(int j = 0; j < i; j++) {
- printf("%c", niza[j]);
- }
- printf("\n");
- brojac++;
- }
- i = 0;
- niza[0] = '\0';
- }
- else if(c == '\n' || c == ' ') {
- i = 0;
- niza[0] = '\0';
- }
- else {
- niza[i] = c;
- i++;
- }
- }
- printf("%d\n", brojac);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment