Skip to content

Instantly share code, notes, and snippets.

@rpt
Created June 1, 2010 19:58
Show Gist options
  • Save rpt/421393 to your computer and use it in GitHub Desktop.
Save rpt/421393 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
int strfindandblank( char *source, char *find ) {
int ile = 0, dalej = 1;
char *pch;
while (dalej!=0) {
pch = strstr (source, find);
if (pch!=NULL) {
memset (source,' ', atoi(pch));
ile+=strlen(find);
}
else dalej=0;
}
return ile;
}
int main() {
char source[200], find[100];
printf("Podaj ciag znakow:\n");
fgets(source, 200, stdin);
printf("Podaj szukana fraze:\n");
fgets(find, 100, stdin);
printf("Zamieniono na spacje %i znakow.\n", strfindandblank(source, find));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment