其实很简单, 做个记录。
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
using namespace std;
#include <string.h>
void getformat(char *tmp)
{
int len = strlen(tmp);
}
int main( void )
{
FILE *fp;
fp = fopen("1.txt" , "r");
fseek( fp , 0 , SEEK_END );
int file_size;
file_size = ftell( fp );
printf( "%d" , file_size );
// char *tmp;
// tmp = (char *)malloc( (file_size+1) * sizeof( char ) );
char tmp[10000];
fseek( fp , 0 , SEEK_SET);
fread( tmp , file_size , sizeof(char) , fp);
tmp[file_size] = '\0';
fclose(fp);
printf("%s" , tmp );
return 0;
}
over。