Hi, I am trying to read into a file that has something like
I have 5 apples and 9 bananas.
Sam has 8 apples and 6 bananas.
and I need to replace the numbers with words. For example I need to change the "5" to five and so on. The problem is that im not sure how to access and then replace just the numbers. Any help will be appreciated.
int main()
{
ifstream in_stream;
in_stream.open("input.dat");
if(in_stream.fail())
{
cout<< "Input file opening failed.\n";
exit(1);
}
string line[30]; // creates SIZE empty strings
int i=0;
while(!in_stream.eof()) {
getline(in_stream,line[i]); // read the next line into the next string
++i;
}
int numLines = i;
for (i=0; i < numLines; ++i) {
cout << i << ". " << line[i]<<endl; // no need to test for empty lines any more
}
Actually, you may try implementing an image converting tool within your applciation, which enables to converting and processing txt file to stream that is in the form of number or data or to byte arrary.