Advertisement
ChrisPetrovski

10.4. Позиција на ред

Dec 19th, 2017
824
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.77 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main(){
  5.     FILE * fpInput;
  6.     fpInput = fopen("text.txt", "r");
  7.     if(NULL == fpInput){
  8.         puts("GRESKA PRI CITANJE DATOTEKA");
  9.         return -1;
  10.     }
  11.     int upperCaseCount=0,lineNum=0,tempCaseCount=0;
  12.     int k=1;
  13.     char red[80];
  14.     while ((fgets(red,80,fpInput))!=NULL){
  15.         int i;
  16.         printf("%d. %s",k,red);
  17.         for(i=0;i<strlen(red);i++)
  18.             if(isupper(red[i]))
  19.                 tempCaseCount++;
  20.             if(tempCaseCount>upperCaseCount){
  21.                 upperCaseCount=tempCaseCount;
  22.                 lineNum=k;
  23.             }
  24.             k++;
  25.             tempCaseCount=0;
  26.         }
  27.     printf("%d RED, %d Bukvi", lineNum,upperCaseCount);
  28.     fclose(fpInput);
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement