Path: utzoo!utgpu!water!watmath!clyde!att!pacbell!ames!mailrus!uwmcsd1!lakesys!chad From: chad@lakesys.UUCP (Chad Gibbons) Newsgroups: comp.lang.c Subject: string manipulation Summary: how to delete a string from another string Keywords: squeeze, string Message-ID: <1061@lakesys.UUCP> Date: 26 Sep 88 00:04:58 GMT Reply-To: chad@lakesys.UUCP (Evil Iggy's illegitimate twin brother) Organization: Lake Systems - Milwaukee, WI Lines: 25 For several applications it would become necessary to remove a small string from a larger one. There appears to be an easy way to do this, and here is a sample piece of code I was testing : char *squeeze(cs, ct) const char cs[]; const char ct[]; { register int i; int j,x; j = strcspn(cs, ct); for (i = j; cs[i] != '\0'; i++) cs[i] = cs[i + x]; return (char *)s; } It seems the algorithm should work. However, if nothing else is wrong, one basically major thing is: you cannot over step the array bounds. If you do, you get a nifty little core dump error. So, I'm looking for a good way to do this. I tried it with pointers, but I had worse luck than with this. For all I know there is some obscure library function to do this, but I didn't find one in our library. Any one have a better way to do it? Post it, inform us all. I'm curious to see if this can be done with explicit pointers and not just with array indexes.