Monday 15 April 2013

c++ - how can I use strcmp_function -


I write a function to find a specific word in a text, but I have a problem, I use strcmp_function I do four arguments, while there is a [] cons four how can I use this function in this function? (W is the word)

  int comparision (const char [], char * w) {int i, length = 0, c = 0, l = 0; Int j, count = 0; Four a [20] = {'0'}; Length = Stellen (sentence); L = Stellen (W); (I = 0; i & lt; length; i ++) {if (sentence [i] == ''] sentence [i] == '\ t' || sentence [i] == '\ n') {For (J = 0; J & lt; L; J ++) a [J] = sentence [J + I + 1]; A [j + 1] = '\ 0'; If (strcmp (a, w) == 0) count ++; }} Return calculation; }    

Why do not you try to do something like

  int i = 0; While (sentence [i]! = '\ 0') {if (strencum (and sentence [i], word, l) == 0) {count + = 1; I + = l; } And I + = 1; } Return (count);   

And you have a problem, because you read the strncmp bus array

No comments:

Post a Comment