int
main(
int
argc, char
*
argv[]) {
std::cout <<
"int 大小: "
<< sizeof(
int
) << std::endl;
std::cout <<
"size_t 大小: "
<< sizeof(size_t) << std::endl;
std::cout <<
"void * 大小: "
<< sizeof(void
*
) << std::endl;
/
/
1
MB 临时数据
const size_t t_size
=
1024
*
1024
;
char
*
t_data
=
new char[t_size];
std::stringstream body;
/
/
写入
1
GB
for
(size_t i
=
0
; i <
1024
; i
+
+
) {
body.write(t_data, t_size);
}
std::cout <<
"文件大小 1: "
<< body.
str
().size() << std::endl;
/
/
再写入
1
GB, 到达临界
for
(size_t i
=
0
; i <
1024
; i
+
+
) {
body.write(t_data, t_size);
}
std::cout <<
"文件大小 2: "
<< body.
str
().size() << std::endl;
/
/
再写入
1
MB, 大小不再改变
body.write(t_data, t_size);
std::cout <<
"文件大小 3: "
<< body.
str
().size() << std::endl;
delete[] t_data;
return
0
;
}