Hello.
I need to write a program that reads from a text file that has a couple words(5-6) and creates another text file that has all thease words except a word that i want to censor
for example
test1.text has 6 words(one word per line). i will have c++ to asking me the word i want to be censored.
Then c++ will make me another text file (test2.txt) with all the words from test1.txt except the word i chose to censor and it should be replaced with
If you use std::string, comparison is just ==. If you use char arrays instead, you need to use strcmp() from <cstring>. strcmp will return 0 if the strings are equal.
Here's pseudocode:
open input file, open output file.
while there is something in the input file
read string S from it
if S is equal to the one you want to censor then
write the replacement string to the output file
else
write S to output file