Emmanuel Par� wrote:
>
> Maybe Pixel can help me with this one...
>
> Recently I have store a entire into a string that work very nice! Now my
> problem is the parsing of that file.. I need to find the 2th occurance of a
> string ex : "WINS" in my MyFileStr. Since strstr only return the first
> occurance I must do a loop and increment the pointer. But my problem is
> very stupid I dont how to strcpy myFileStr ro NextSearchPtr the problem I
> think is the declaration of NextSearchPtr if I declare it like char
> NextSearchPtr[3000]; (<- not elegant) its ok for the strcpy but not work in
> the function (not a pointer),... Damn I am really confuse...
>
> A C++ beginner..
>
(this is pure C but ah well...)
int nr_occurencies(const char *haystack, char *needle){
int res=0;
int len=strlen(needle);
char *p=haystack;
while(p=strstr(p, needle)){
++res;
p += len;
}
return res;
}
--
fg
# rm *;o
o: command not found