-
Regcomp?
I'm making my first C script, it logs on to a website and checks if it succeeded. Therefor, I need to check if the page contains "Je bent nu ingelogd". The website is saved in char *res.
Can anyone help? I wanted to use regcomp but I didn't understand the man page and I couldn't find any good example on this site or google.
Thanks!
-
Write your own search function.
It isn't so hard.
-
Well, for me it is, this is my first C script 8-)
-
Go back to Hello World and tutorials then! :D
-
>Write your own search function.
>It isn't so hard.
The actual search isn't terribly difficult, but connecting to a web server and downloading the contents of a page isn't exactly trivial.
>Well, for me it is, this is my first C script 8-)
You probably don't want to do it in C. I would tend more toward Perl for something like this.
-
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.
-
>I wouldn't use scripting languages in real programs.
Why not?
>This is some kind of a search function. It is terrible and may be buggy, so beware:
It's a good thing standard C provides strstr. ;)
-
Because it is a SCRIPTING language, not a PROGRAMMING language. It needs INTERPRETER.
I have already told it's a lot more fun to make the whole function myself.
-
>Because it is a SCRIPTING language, not a PROGRAMMING language. It needs INTERPRETER.
Excuse me, I need to go beg webmaster for a "stunned silence" smiley.
>I have already told it's a lot more fun to make the whole function myself.
I don't have a problem with that. What I have a problem with is your completely ignoring a better solution and making a beeline to your own naive code. You can post your own implementation if you want, but please do so after properly answering the question to the best of your ability.
-
You should have seen by now that every single thing maxorator says is ... I can't even locate the correct word. Inept? Pointless? Wrong? Eye-bleed-inducing? I'm going to have to start making up words for it.
Quzah.
-
>I'm going to have to start making up words for it.
Just call him a Mister C and be done with it. ;) Ah, I kill me. That reminds me to read his book on C#...