0

I have a .txt file that contains a lot of text. I will read the whole text file and output a new textfile with one change that is this:

The txt file that I will read could for example look like this:

Value1 Value2 Value3[]
Value4 Value5[]

What I am trying to do is to change all "[" to "x["
So the lines will look like this instead:

Value1 Value2 Value3x[]
Value4 Value5x[]


What could be the approach I will think about here ?

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Jennifer84
0
std::ifstream fin( "file1.txt" ) ;
std::ofstream fout( "file2.txt" ) ;
fin >> std::noskipws ;
char ch ;
while( fin >> ch )
{
  if( ch == '[' ) fout << 'x' ;
  fout << ch ;
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.