Help with the lines.



  • The word is inserted from the keyboard. Determine how many times the words "n" appear.

    Help me find mistakes. Sort of a rule, but why doesn't he think?

    #include "stdafx.h" 
    #include <string.h>
    #include <iostream>
    using namespace std;
    

    int main() {
    setlocale(LC_CTYPE, "Russian");
    int n = 0;
    char * s;
    s = new char[100];

    cin &gt;&gt; s;
    
    while ((s = strstr(s, "нн")) != NULL) {
        n++;
        s += 2
    }
    delete s;
    cout &lt;&lt; "count words:" &lt;&lt; n;
    system("pause");
    return 0;
    

    }



  • The problem of this code is not the code, but the coding of the original file. The coding of the O.R. system consoles is different from the file code, so the Russian are different. For everything to work properly, we need the original file coding to match the console code. In case Windows default coding - CP866 (Doc. 866). Secure the source in this code and make it work.


Log in to reply
 


Suggested Topics

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