•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 402,632 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,299 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
How might I write an implementation in C of the standard library function
strstr? Here's how I might.
#include <stdio.h> char *mystrcat(char *dst, const char *src) { char *start = dst; while ( *dst ) { ++dst; /* find the current end of the string */ } while ( *dst++ = *src++ ) ; /* copy from 'src' up to and including the terminating null character */ return start; } int main (void) { char text[12] = "Hello"; puts(mystrcat(text, " world")); return 0; } /* my output Hello world */
Post Comment
•
•
•
•
DaniWeb Marketplace (Sponsored Links)