tfelb wrote:
I bought the book "Programming in C" by Stephen G Kochan. I miss
2 answers at his website. (removestr and the substr function)
How can I implement these functions? It would be wonderful if
someone can help me out, because Stephen Kochan is not reachable.
... snip ...
Why don't you post the requirements for both of these functions,
and the code you've written so far, and we'll see if we can
assist you in getting it right.
These are the functions of Stephen G Kochan posted on his website,
but to answer my book questions I miss the substr and removestr
function to understand how these functions are implemented.
int findString (const char source[], const char s[])
... snip much code ...
You posted all that but didn't bother to answer Lews question.
Describe, in detail, what those functions (substr and removestr)
do. Include a complete prototype.
--
Chuck F (cbfalconer at maineline dot net)
<
http://cbfalconer.home.att.net>
Try the download section.
--
-ZitiertenTextausblenden-
- Zitierten Text anzeigen -
Thanks for all!- Zitierten Text ausblenden -
- Zitierten Text anzeigen -
I coded the substring function and it works fine but I have problems
with the removestr function. I want to code this function without any
pointers. I'm not sure how can I delete a char in C because '\0' is
the end of each string and it terminates the string. I tried to set
dst
= ""; but then I got an errormessage "warning: assignment makes
integer from pointer without a cast", so "" doesn't work.
Thanks for any help!
Tom
Prototyp: void removestr(char [], char [])
Use:
char string[100] = "This is a text\n";
removestr(string,"This");
printf("%s",string) /* the result should be "is a text" */
void removestr (char dst[], char find[])
{
int i,l;
for(i = 0, l = 0; dst != '\0' && find[l] != '\0'; i++, l++)
if(dst == find[l])
{
dst = '\0'; /* I think here is the problem because it terminates
the whole dst */
}
dst = '\0';
}