环境:DOS, BC or TC
问题:读取文件的时候,如果文件太大,那么程序就会不正常退出,没有什么提示信息,仅仅只有:program abnormally terminated. 经过反复测试,当文件大小>=34309bytes时候(占用空间恰好为40KB),程序就会不正常退出,否则就可以正常读取。
请问是什么原因?编译器模式?还是DOS缓冲区大小限制?怎么解决?
...全文
657打赏收藏
读写大文件
环境:DOS, BC or TC 问题:读取文件的时候,如果文件太大,那么程序就会不正常退出,没有什么提示信息,仅仅只有:program abnormally terminated. 经过反复测试,当文件大小>=34309bytes时候(占用空间恰好为40KB),程序就会不正常退出,否则就可以正常读取。 请问是什么原因?编译器模式?还是DOS缓冲区大小限制?怎么解决?
ok, you are right.
I use the count variable, which type is INT, to record how many bytes read. So when the file size is greater than MAX_INT, maybe the array will overflow(minus index).Now I changed its type to LONG. OK,it works now.
OK, 下面是源代码的一部分
/*
filePath: the absolute path of file which is to add stamp
stamp: the file's stamp which length is 16
*/
void getStamp(char* filePath,char* stamp)
{
FILE* file;
int count=0,charRead;