Advertisement
Lubino41

Untitled

Nov 24th, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. int main ( void )
  5. {
  6.  
  7. char *najdi;
  8. int ch = 0 ,i,c = 0, number_of_lines = 0; //number_of_lines = -1;
  9. static const char filename[] = "buu.txt";
  10. FILE *file = fopen ( filename, "r" );
  11. if ( file != NULL )
  12. {
  13. char line [128]; /* or other suitable maximum line size */
  14. while ( fgets ( line, sizeof line, file ) != NULL ) /* read a line */
  15. {
  16. number_of_lines++;
  17.  
  18.  
  19. if(number_of_lines <5 && number_of_lines > 3 )
  20.  
  21. // ak mam 80 riadkov deleno pocet procesov {4} = 20 = RIADKY
  22. //if(number_of_lines > (rank*RIADKY) && number_of_lines =< (rank+1)*RIADKY )
  23.  
  24. {
  25.  
  26.  
  27.  
  28. printf ("hladam znak 'a' v retazci %s", line);
  29. najdi = strchr(line,'a');
  30.  
  31. while (najdi != NULL)
  32. {
  33. //printf ("najdeny na %d pozicii retazca\n",najdi - line + 1);
  34. najdi = strchr(najdi+1,'a');
  35. ch = ch + 1;
  36. }
  37. }
  38.  
  39. }
  40.  
  41. fclose ( file );
  42. printf ("pocet najdenych znakov celkovo: %d \n",ch);
  43. printf("pocet riadkov suboru je: %d ", number_of_lines);
  44. }
  45.  
  46.  
  47. else
  48. {
  49. perror ( filename ); /* why didn't the file open? */
  50. }
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement