I am trying to read a file and then print it but the loop doesn't ends. Why??
My file contains one line such as
66,67,256,258,69,73,
This is my input :
char d;
char code2 [12]={0};
string file1;
cout<<"Input file name"<<endl;
cin>>file1;
string file2;
cout<<"Input file name"<<endl;
cin>>file2;
ifstream input;
input.open(file1.c_str());
ofstream output;
output.open(file2.c_str());
while(! input.eof())
{
int i=0;
while(d != ',' && i < sizeof(code2))
{
input>>d;
code2[i]=d;
i++;
}
file2<<code2;
}
While debugging, I am getting a garbage value of code2. Thus, the loop doesn't ends at end of while.