[Please don't comment on using Turbo C++. I know that it's obsolete but we are taught this way only.] Somewhat similar kind of error is here Why do I get a 'ÿ' char after every include that is extracted by my parser? - C but I couldn't relate it to my code - Well I'm a newbie.
#include<fstream.h>
#include<conio.h>
void main()
{
clrscr();
char ch;
ifstream read_file;
read_file.open("Employee.txt");
ofstream write_file;
write_file.open("Another.txt");
while(!read_file.eof())
{
/*Also when I use, write<<read_file.get(ch) in this block instead of the two statements below, it writes some kind of address in the file. Please tell me about that too why it happens. */
read_file.get(ch);
write_file<<ch;
}
read_file.close();
write_file.close();
getch();
}
The problem I'm facing is that it appends ÿ character at the end of 'another' file.
eg: the text in "Employee" is, ID:1 Name:abc then the text it copies to "another" is: ID:1 Name:abcÿ