#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main() {
// Liste von Wörtern die du verbieten willst
const char* blocked_words[] = {"wort1", "wort2", "test"};
int num_words = 3;
char input[500];
printf("Gib Text ein: ");
fgets(input, 500, stdin);
// Geht alle verbotenen Wörter durch
for(int i = 0; i < num_words; i++) {
char* pos = strstr(input, blocked_words[i]);
while(pos!= NULL) {
// Ersetzt das Wort durch ***
for(int j = 0; j < strlen(blocked_words[i]); j++) {
pos[j] = '*';
}
pos = strstr(pos + 1, blocked_words[i]);
}
}
printf("Gefilterter Text: %s", input);
return 0;
}
#include <string.h>
#include <ctype.h>
int main() {
// Liste von Wörtern die du verbieten willst
const char* blocked_words[] = {"wort1", "wort2", "test"};
int num_words = 3;
char input[500];
printf("Gib Text ein: ");
fgets(input, 500, stdin);
// Geht alle verbotenen Wörter durch
for(int i = 0; i < num_words; i++) {
char* pos = strstr(input, blocked_words[i]);
while(pos!= NULL) {
// Ersetzt das Wort durch ***
for(int j = 0; j < strlen(blocked_words[i]); j++) {
pos[j] = '*';
}
pos = strstr(pos + 1, blocked_words[i]);
}
}
printf("Gefilterter Text: %s", input);
return 0;
}
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main() {
// Liste von Wörtern die du verbieten willst
const char* blocked_words[] = {"wort1", "wort2", "test"};
int num_words = 3;
char input[500];
printf("Gib Text ein: ");
fgets(input, 500, stdin);
// Geht alle verbotenen Wörter durch
for(int i = 0; i < num_words; i++) {
char* pos = strstr(input, blocked_words[i]);
while(pos!= NULL) {
// Ersetzt das Wort durch ***
for(int j = 0; j < strlen(blocked_words[i]); j++) {
pos[j] = '*';
}
pos = strstr(pos + 1, blocked_words[i]);
}
}
printf("Gefilterter Text: %s", input);
return 0;
}
0 Comments
0 Shares
124 Views