int fread(char cc[],int a[],int q)
{
ifstream infile;
infile.open("C:\Dev-Cpp\DCS\Decom\a.txt",ios::binary);
infile.read(cc,257);
infile.close();
for(int i=0;i<256;i++){a[i]=(unsigned char)cc[i];}
return 0;
}
现在,q 从表面反面获得价值,这里是我想要做的事,
if q is 0, it reads the first 256 characters and if q is 1, it reads the characters from position 256 to 512 and so on
这样做的正确方式,取决于并具有一系列规模256,或者是否有更有效的方法这样做?
int fread(char cc[],int a[],int q)
{
int ka=0,kb=0;
kb=q*256;
ka=ka+256;
ifstream infile;
infile.open("C:\Dev-Cpp\DCS\Decom\a.txt",ios::binary);
infile.seekg(256);
infile.read(cc,ka);
infile.close();
for(int i=0;i<256;i++){a[i]=(unsigned char)cc[i];}
return 0;
}
I m getting a Unhandled exception at 0xb9fb2475 in s949.exe: 0xC0000005: Access violation reading location 0xb9fb2475 when i debug it in vc++ 2010.