Okay, so i've written the function and it seems to work. The outline was to write a function with this signature: char* findx(char*s, char*x), that finds multiple occurences of string s in x.
My code is:
As I said, this seems to work fine. Can anybody see anything wrong with it?Code:char* findx(char* s, char* x) { int lens = strlen(s); int lenx = strlen(x); int count = 0; int found = 0; for(int i = 0; i < lenx; ++i) { for(int j = count; j < lens; ++j) { if(s[j] == x[i]) { ++ count; break; } count = 0; } if(count == lens){ ++found; count = 0; } } cout << found; return s; }
Thanks.



LinkBack URL
About LinkBacks




