Help me write a word-account program on C.



  • The challenge is to calculate the number of words in the text. We need to write on C.

    That's what you wrote:

    int main()
    {
       char s[100];
       int k;
       FILE *f1 = fopen("ServerSocket1.txt", "r");
       while(fgets(s, 100, f1))
       {
            if(strstr(s,"библиотек") != NULL) //здесь хотел чтобы если в строке есть совпадение, то к счетчику прибавляем 1
                k++;
       }
        printf("%d", k);
        return 0;
    }
    


  • The strstr coding curve doesn't count anything. I don't know where you're taking this file. But try to create a text file with a few words you need and keep it, for example, in utf8. First, do it in the Latin. And then check in the kyril.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2