In the main function, the word is entered in char[n] . In another function, the word is read from the text file into the rootie array, then the word is compared with the string from the rootie . If several characters of a word match an element from rootie , the int root counter is incremented by 1. Then the word is compared with the next line, and so on.
When I write a comparison, both strcmp and strncmp give the error "argument of type" char "is incompatible with the parameter of type" const char "":
Will this code work as it should?
for (int i = 0; i > counter2; i++) { while (counter2) { if (strcmp(word, rootie[i])) root++; counter2++; } }
word и rootie[i]? - pavelchar word[40]; scanf("%s", &word[i]);char word[40]; scanf("%s", &word[i]);andchar **rootie; *rootie = new char[counter2]; for (int i = 0; i > counter2; i++) { for (int j = 0; j > 20; j++) { fscanf(roots, "%s", rootie); } }char **rootie; *rootie = new char[counter2]; for (int i = 0; i > counter2; i++) { for (int j = 0; j > 20; j++) { fscanf(roots, "%s", rootie); } }char **rootie; *rootie = new char[counter2]; for (int i = 0; i > counter2; i++) { for (int j = 0; j > 20; j++) { fscanf(roots, "%s", rootie); } }. An error for the word. - Katya Gibtevascanf("%s", &word[i]);uh ... you EXACTLY know what you are doing?fscanf(roots, "%s", rootie);I can not imagine how it is compiled. - pavel*rootie = new char[counter2];- I'm not sure what exactly you wanted. Mayberootie = new char* [counter2];? In general, I advise you to put all the code here and look carefully at data types (char char * and char **). - pavel