-
-
Save rpt/421428 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
int strfindandblank( char *source, char *find ) { | |
int ile = 0; | |
int find_size = strlen(find); | |
char *pch; | |
pch = strstr(source, find); | |
while(pch!=NULL) { | |
memset(pch, ' ', find_size); | |
ile += find_size; | |
pch = strstr(source, find); | |
} | |
return ile; | |
} | |
/** | |
* Funkcja zamieniajaca pierwszy znaleziony enter na koniec stringa. | |
*/ | |
void strip(char *str) { | |
int i; | |
for(i=0; i<strlen(str); i++) | |
if(str[i] == '\n') { | |
str[i] = '\0'; | |
break; | |
} | |
} | |
int main() { | |
char source[1024]; | |
char find[1024]; | |
printf("Podaj ciag znakow: "); | |
fgets(source, 1024, stdin); | |
strip(source); | |
printf("Podaj szukana fraze: "); | |
fgets(find, 1024, stdin); | |
strip(find); | |
printf("Zamieniono na spacje %i znakow.\n", strfindandblank(source, find)); | |
printf("Napis wyglada teraz tak: %s\n", source); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment