Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- int main ( void )
- {
- char *najdi;
- int ch = 0 ,i,c = 0, number_of_lines = 0; //number_of_lines = -1;
- static const char filename[] = "buu.txt";
- FILE *file = fopen ( filename, "r" );
- if ( file != NULL )
- {
- char line [128]; /* or other suitable maximum line size */
- while ( fgets ( line, sizeof line, file ) != NULL ) /* read a line */
- {
- number_of_lines++;
- if(number_of_lines <5 && number_of_lines > 3 )
- // ak mam 80 riadkov deleno pocet procesov {4} = 20 = RIADKY
- //if(number_of_lines > (rank*RIADKY) && number_of_lines =< (rank+1)*RIADKY )
- {
- printf ("hladam znak 'a' v retazci %s", line);
- najdi = strchr(line,'a');
- while (najdi != NULL)
- {
- //printf ("najdeny na %d pozicii retazca\n",najdi - line + 1);
- najdi = strchr(najdi+1,'a');
- ch = ch + 1;
- }
- }
- }
- fclose ( file );
- printf ("pocet najdenych znakov celkovo: %d \n",ch);
- printf("pocet riadkov suboru je: %d ", number_of_lines);
- }
- else
- {
- perror ( filename ); /* why didn't the file open? */
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement