-1
如何在C++中的char數組中逐行讀取二進制文件? 這樣的:二進制C++中的文件讀取
struct packet
{
unsigned int ack;
char data[994];
int sequence_number;
unsigned long checksum;
int lenghtFile;
}dummy;
fstream file1;
file1.open("filename.txt",ios::binary);
if(!file1)
{
cout<<"\n error opening file \n";
}
else
{
while(1)
{
if(file1.eof()!=0)
{break;}
else
{//
file1.read(dummy.data,994);
sendto(connfd,(struct packet*)&dummy,sizeof(struct packet),0,
(sockaddr*)&server,sizeof(server));
}
}
}
如何被存儲在文本文件中的數據? – woolstar
什麼不適合你? – jxh
'二進制行文件'我現在停止閱讀了。 –