#include <stdio.h>
void setbuf(FILE * stream, char * buf);
#include <stdio.h>
char outbuf[BUFSIZ];
int main(void)
{
setbuf(stdout, outbuf); // 把缓冲区与流相连
puts("This is a test of buffered output.\n");
puts(outbuf);
fflush(stdout); // 刷新
puts(outbuf); // 输出
return 0;
}
This is a test of buffered output.. This is a test of buffered output.. This is a test of buffered output.. This is a test of buffered output..
#include <stdio.h>
int setvbuf(FILE * stream, char * buf, int type, unsigned size);
#include <stdio.h>
int main(void)
{
FILE *input, *output;
char bufr[512];
input = fopen("file.in", "w+"); /*打开文件*/
output = fopen("file.out", "w");
if (setvbuf(input, bufr, _IOFBF, 512) != 0) /*失败*/
{
printf("failed to set up buffer for input file\n");
}
else
{
printf("buffer set up for input file\n");
}
if (setvbuf(output, NULL, _IOLBF, 132) != 0) /*为流指定特殊的缓冲区*/
{
printf("failed to set up buffer for output file\n");
}
else
{
printf("buffer set up for output file\n");
}
fclose(input);
fclose(output);
return 0;
}
Buffer set up for input file Buffer set up for output file
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有