Expression: *file !=_T(‘\0’)File:fopen.c line:54
//输入文件,统计文件的字节长度
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include "function1.h"
using namespace std;
void function1()
{
cout<<endl;
char filename[256];
long length;
cout<<"请输入文件名:";
gets(filename);
FILE *fp=fopen(filename,"rb");//以二进制读文件方式打开文件
if( fp==NULL)
cout<<"file not found!\n";
else
{
fseek(fp,0L,SEEK_END);//把文件的位置指针移到文件尾
length=ftell(fp);//获取文件长度;
printf("该文件的长度为%1d字节\n",length);
}
fclose(fp);
getch();
}
为什么老是会出现标题所示错误呢!?
假如是单一创建的话,又可以运行……
int main(int argc, char* argv[])
{
cout<<"欢迎使用文件操作软件"<<endl<<endl;
cout<<"本软件功能介绍:1、统计文件字节数;2、选择性文件复制;3、文件合并;4、文件比较;5、内容查找"<<endl;
int function;
cout<<"请输入 1、2、3、4、5以选择文件操作功能:";
cin>>function;
if(function==1)
function1();