I'm writing a code that will take a word and a text to be examined from stdin and censored the word if it appears in the text. That's my code so far, but when I compile the code it produces error below.
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(int argc, char* argv[])
{
char censor[] = "CENSORED";
char input[1028];
for(int i = 1; i < argc; i++){
if(strstr(input, argv[i]) != NULL){
for(int j = 0; j < strlen(input); j++){
if(strcmp(input[j], argv[i]) == 0){
input[j] = censor;
}
}
}
}
printf("%s", input);
printf("\n");
}
censored.c: In function ‘main’: censored.c:13:15: warning: passing argument 1 of ‘strcmp’ makes pointer from integer without a cast [-Wint-conversion] if(strcmp(input[j], argv[i]) == 0){ ^ In file included from censored.c:3:0: /usr/include/string.h:140:12: note: expected ‘const char *’ but argument is of type ‘char’ extern int strcmp (const char *__s1, const char *__s2) ^ censored.c:14:15: warning: assignment makes integer from pointer without a cast [-Wint-conversion] input[j] = censor;
I'm not sure why they think the char array is an integer, please help, thanks!