This should be easy to answer.
I have a file with many lines of numbers
ie: 3+4/8
8-(5+3)
....
Anyway, I need to add the $ character to the end of each line. I forgot how to do this however. I was trying to do a search for a new line and then insert, but I forgot if when doing a while loop to check if it tries to add the character afterwards...Take a look at my code and give any suggestions.
Thanks
Code:
#include <iostream>
#include <fstream>
using namespace std;
ifstream infile;
ofstream outfile;
int main()
{
char tok;
infile.open("data.dat");
infile >> tok;
while (!infile.eof())
{
while(tok='\n')
{
outfile << '$';
infile >> tok;
}
}
return 0;
}