Well, first off you need to return a value from the function. That value can be stored in a data structure, or placed directly into the out file. How about placing both the in and the out in the same "while" loop like this:
CODE
int num(char ch) {
int returnValue;
if(ch == '\n')
cout << endl;
if(ch == 'a' || ch == 'A' || ch == 'b' || ch == 'B' || ch == 'c' || ch == 'C') {
cout << "2"; returnValue = '2';
}
if ...
..
return returnValue;
}
...
int main (){
ifstream in;
ofstream out;
in.open("numbers.txt");
out.open("numbers2.txt");
while(!in.eof()){
ch = in.get();
out << num(ch);
}
in.close();
out.close();
return 0;
}
This avoids saving the values in a data structure, but it also avoids formating the data in a useful way. A "case" statement would work better than all those "if" statements, also.
This post has been edited by ajwsurfer: 23 Jan, 2008 - 08:02 AM