http://www.oschina.net/code/snippet_166355_9332
任何的C编译器,任何平台
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include "stdio.h"
#include "string"
#include "stdlib.h"
using
namespace
std;
int
main(
void
)
{
FILE
*fp;
fp =
fopen
(
"05.爱,九把刀系列之那些年,我们一起追的女孩.txt"
,
"r"
);
fseek
( fp , 0 , SEEK_END );
int
file_size;
file_size =
ftell
( fp );
printf
(
"%d"
, file_size );
char
*tmp;
fseek
( fp , 0 , SEEK_SET);
tmp = (
char
*)
malloc
( file_size *
sizeof
(
char
) );
fread
( tmp , file_size ,
sizeof
(
char
) , fp);
printf
(
"%s"
, tmp );
return
0;
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include "stdio.h"
#include "string"
#include "stdlib.h"
using
namespace
std;
int
main(
void
)
{
FILE
*fp;
fp =
fopen
(
"05.爱,九把刀系列之那些年,我们一起追的女孩.txt"
,
"r"
);
fseek
( fp , 0 , SEEK_END );
int
file_size;
file_size =
ftell
( fp );
printf
(
"%d"
, file_size );
char
*tmp;
fseek
( fp , 0 , SEEK_SET);
tmp = (
char
*)
malloc
( file_size *
sizeof
(
char
) );
fread
( tmp , file_size ,
sizeof
(
char
) , fp);
printf
(
"%s"
, tmp );
return
0;
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include "stdio.h"
#include "string"
#include "stdlib.h"
using
namespace
std;
int
main(
void
)
{
FILE
*fp;
fp =
fopen
(
"05.爱,九把刀系列之那些年,我们一起追的女孩.txt"
,
"r"
);
fseek
( fp , 0 , SEEK_END );
int
file_size;
file_size =
ftell
( fp );
printf
(
"%d"
, file_size );
char
*tmp;
fseek
( fp , 0 , SEEK_SET);
tmp = (
char
*)
malloc
( file_size *
sizeof
(
char
) );
fread
( tmp , file_size ,
sizeof
(
char
) , fp);
printf
(
"%s"
, tmp );
return
0;
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include "stdio.h"
#include "string"
#include "stdlib.h"
using
namespace
std;
int
main(
void
)
{
FILE
*fp;
fp =
fopen
(
"05.爱,九把刀系列之那些年,我们一起追的女孩.txt"
,
"r"
);
fseek
( fp , 0 , SEEK_END );
int
file_size;
file_size =
ftell
( fp );
printf
(
"%d"
, file_size );
char
*tmp;
fseek
( fp , 0 , SEEK_SET);
tmp = (
char
*)
malloc
( file_size *
sizeof
(
char
) );
fread
( tmp , file_size ,
sizeof
(
char
) , fp);
printf
(
"%s"
, tmp );
return
0;
}
|