home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!sun-barr!cs.utexas.edu!sdd.hp.com!ux1.cso.uiuc.edu!usenet.ucs.indiana.edu!navajo!shulick
- From: shulick@navajo.ucs.indiana.edu (Sam Hulick)
- Subject: HIgher problems at hand. HELP!
- Message-ID: <Brv6oD.Dq5@usenet.ucs.indiana.edu>
- Originator: shulick@navajo
- Sender: news@usenet.ucs.indiana.edu (USENET News System)
- Nntp-Posting-Host: navajo.ucs.indiana.edu
- Reply-To: shulick@navajo.ucs.indiana.edu
- Organization: Vallen Software
- Date: Thu, 23 Jul 1992 23:02:36 GMT
- Lines: 36
-
-
- int strstr(char *data, char *chunk)
- {
- static int x;
-
- for (x=0;x<strlen(data); ++x) {
- if (!strncmp(chunk, &data[x], strlen(chunk)))
- return x+1;
- }
- return 0;
- }
-
- What's wrong with this subroutine? I'm making strstr() since Amiga C
- doesn't have it.
- I do stuff like .. d = strstr("foobar", "bar");
- and d comes up like 139579275 or some weird value, where it's SUPPOSED to
- return either 0 (not found) or some value x, where x is the position in the
- string where "bar" starts. When I say
-
- int strstr(char *data...
-
- Can I pass both *str and str[25]? For instance..
-
- char *blah;
-
- s = strstr(blah.... /* after malloc()'ing it, of course */
-
- or char blah[50]; Could either blah be passed into strstr as a (char *)?
-
- Again, reply via email, please. shulick@indiana.edu
- Thanks.
-
- --
- Sam Hulick /// E-mail: shulick@indiana.edu (including NeXT mail)
- ------------------------------------------------------------------------
- "The pen is the mouth and the paper is the soon-to-be-wise one."
-