I wouldn't use scripting languages in real programs.
I would use scripting languages in web sites.
This is some kind of a search function. It is terrible and may be buggy, so beware:
Code:
int search(char* data,char* find){
int i,match=0,findlen,start;
if(find[0]=='\0'){
return -1;
}
findlen=strlen(find);
for(i=0;data[i]!='\0';i++){
if(data[i]==find[match]){
if(match==0){
start=i;
}
match++;
if(match==findlen){
return start;
}
}
else{
if(match>0){
match=0;
if(data[i]==find[0]){
start=i;
match=1;
if(findlen==1){
return start;
}
}
}
else{
match=0;
}
}
}
return -1;
}
If the second string is found in the first string, then it returns the location where it starts.
Otherwise it returns -1.