#include<stdio.h>
#include<string.h>
int main( int argc, char* argv[] )
{
int a,k; int match =0; int lenCurrent; int diff = 0;
// argc = number of words +1
while(a != EOF){
a = getchar();
if( a == EOF){ break; }
// tries to see if a matches argv
diff = 0;
for( int i =1; i< argc; i++){
//if( censored == 1 ){
// break;
//}
match = 0;
if( a == argv[i][0] ){
printf("%c", (char)a);
// iterates through the text file to match the argv
for( int j=1; j != 0; j++ ){
a = getchar();
if( a == argv[i][j] ){
match++;
if(match == strlen(argv[i])-1){
printf("\b%s", "CENSORED");
break;
}
} else {
printf("%c", (char)a);
break;
}
}
} else {
// if the char does not equal to the one in the string
diff++;
}
}
if( diff == argc-1 ){
printf("%c", (char)a);
}
}
return 0;
}
No comments:
Post a Comment