BlueBear icon

pointre.c

BlueBear | PRO | 03/06/13 09:36:50 AM UTC | 0 ⭐ | 429 👁️ | Never ⏰ | []
C |

1.79 KB

|

None

|

0 👍

/

0 👎

#include <stdio.h>
#include <stdlib.h>
 
#define SUBOR "ZNAKY.TXT"
 
int cislica(char c);
int male_pismeno(char c);
int velke_pismeno(char c);
int biely(char c);
void zisti(int (*p_func)(), FILE *file);
 
int main(void)
{
    FILE *file = fopen(SUBOR, "r");
    int n = 0;
    char vyber;
 
    if (file == NULL)
    {
        fprintf(stderr, "Chyba pri otvarani suboru s menom: %s\n", SUBOR);
        exit(1);
    }
    rewind(file);
    while(1)
    {
        scanf("%d", &n);
        if(n > 4)
        {
            fprintf(stderr, "Bol zadany vacsi pocet, nez sa da. Maximum co mozete zadat, je 4.\n");
            continue;
        }
        else
        {
            break;
        }
    }
    getchar();
 
    for(n; n > 0; n--)
    {
        vyber = getchar();
        getchar();
        if(vyber == 'b')
        {
            zisti(biely, file);
        }
        else if(vyber == 'v')
        {
            zisti(velke_pismeno, file);
        }
        else if(vyber == 'm')
        {
            zisti(male_pismeno, file);
        }
        else if(vyber == 'c')
        {
            zisti(cislica, file);
        }
    }
    if (fclose(file) == EOF)
    {
        fprintf(stderr, "Chyba pri zatvarani suboru s menom: %s\n", SUBOR);
        exit(1);
    }
    return 0;
}
 
void zisti(int (*p_func)(), FILE *file)
{
    int occur = 0;
    while(!feof(file))
    {
        if(p_func(fgetc(file)))
        {
            occur++;
        }
    }
    printf("%d\n", occur);
    rewind(file);
 
}
 
int cislica(char c)
{
    return (c <= '9' && c >= '0');
}
 
int male_pismeno(char c)
{
    return (c <= 'z' && c >='a');
}
 
int velke_pismeno(char c)
{
    return (c <= 'Z' && c >= 'A');
}
 
int biely(char c)
{
    return (c <= ' ');
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  • Syutrsz icon
    03/31/26 11:00:53 PM UTC
    text |

    0 B

    |

    0 👍

    /

    0 👎

    Best t33n active cpx link daily updates!
     Copy and paste the link in a new browser tab and then hit enter!
     https://crazyporn.@xxx/members/157354/?asgtbndr=1&play=true&spon=adworld&zone=400
     Remove the @ 
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎