|
-
February 1st, 2002, 06:32 AM
#1
Reading from a file including null character
I have some contents in 1 file.Iam reading that into an other file.But it stops reading when it encounters the null character.Is there any other fuction which reads the entire file if the file contains Null also.I want to read the entire file.
I have the following code:
const char cCc ={'\x5A'};
const char Length [] = {'\x00','\x00'};
const char IDM[] = {'\xD3','\xAB','\xCA','\x00','\x00','\x00'} ;
//*A class
class C_ptx
{
public:
C_ptx()
{
m_ptx.open("First",ios: ut|ios::binary);
}
void Createstream()
{
m_ptx.write(&cCc,sizeof(cCc));
m_ptx.write(Length,sizeof(Length));
m_ptx.write(IDM,sizeof(IDM));
}
ofstream & returnstream()
{
return m_ptx;
}
private:
ofstream m_ptx;
};
*/class ends here
/*Main Fuction*/
void main()
{
C_ptx T1;
T1.Createstream();
ofstream& s1 =T1.returnstream();
if(!s1.eof())
{
s1.seekp(0,ios::end);
}
int s =s1.tellp();
char *buffer= new char[s];
ifstream r1("First",ios::in|ios::binary);
// Here When Iam reading from the "First" file it stops reading when it encounters the null character.Is there any other fuction which reads the entire file if the file contains Null
r1.getline(buffer,s);
ofstream m_mixeddata("second",ios: ut|ios::binary);
m_mixeddata.write(buffer,sizeof(buffer));
}
Help!!
Kohinoor
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|