当前位置:网站首页>Printf function buffer problem
Printf function buffer problem
2022-07-27 14:24:00 【Remember to look up at the stars】
A recently executed code , Use printf When , Forget to add \n 了 , The result has not been printed . Check the program configuration and logic repeatedly , No problem. . Wasted half a day , Finally, I found that I stepped into the pit .., This situation is hereby recorded .
The following code , If not printf("\n") or fflush(stdout) Will not show printf Result . Or change to printf("%s\n", str1) Will display the print results .
You can also put while(1); Get rid of , The program can also be refreshed after execution printf The buffer , Print out the results .
This is related to printf Of buffer It matters .
#include <stdio.h>
int main(int argc, char **argv)
{
char *str1 = "str1 printing...";
char *str2 = "str2 printing...";
printf("%s", str1);
printf("%s", str2);
// printf("\n");
// fflush(stdout);
while(1);
return 0;
}
Buffer refresh condition :
1. End of process .
2. encounter \n.
3. Buffer full . printf The buffer size of the function is 1024 Bytes , When the buffer size is exceeded , The buffer will be flushed , The results will be printed .
4. Refresh buffer manually fflush(stdout).
5. call exit(0); But you can also call _exit(0), Do not flush the buffer .
边栏推荐
- [training day3] section [greed] [two points]
- How to test and decrypt the encryption interface
- Rtl8762dk environment construction (I)
- Golang excellent open source project summary
- watch VS watchEffect
- 文献翻译__tvreg v2:用于去噪、反卷积、修复和分割的变分成像方法(部分)
- WPF visifire.charts4.6.1 tutorial with source code
- MySQL advanced II. Logical architecture analysis
- HDU4565 So Easy! [matrix multiplication] [derivation]
- How to view revenue and expenditure by bookkeeping software
猜你喜欢

Chinese character style transfer --- antagonistic discriminative domain adaptation (L1)

Document translation__ Tvreg V2: variational imaging method for denoising, deconvolution, repair and segmentation (part)

uniapp的request数据请求简单封装步骤

汉字风格迁移篇---对抗性区分域适应(L1)Adversarial Discriminative Domain Adaptation

面向流行性疾病科普的用户问题理解与答案内容组织

West test Shenzhen Stock Exchange listing: annual revenue of 240million, fund-raising of 900million, market value of 4.7 billion

面向不平衡数据的电子病历自动分类研究

Pure C handwriting thread pool

Chapter 3 business function development (add clues and remarks, and automatically refresh the added content)

How to view revenue and expenditure by bookkeeping software
随机推荐
Navicate报错access violation at address 00000000
STM32——电容触摸按键实验
PROFINET 模拟器使用教程
Getting started for beginners: build your own blog with WordPress
[related contents of multithreading]
Unity3D学习笔记10——纹理数组
poj3461 Oulipo【KMP】
C#测量工具示意图
一篇文章看懂JS执行上下文
Mining enterprise association based on Enterprise Knowledge Map
printf函数缓冲区问题
初学者入门:使用WordPress搭建一个专属自己的博客
Lighting 5g in the lighthouse factory, Ningde era is the first to explore the way made in China
西测测试深交所上市:年营收2.4亿募资9亿 市值47亿
Flexible and easy to use WYSIWYG visual report
CARLA 笔记(04)— Client 和 World (创建 Client、连接 World 、批处理对象、设置 Weather、设置 Lights、World snapshots)
阿里最新股权曝光:软银持股23.9% 蔡崇信持股1.4%
「游戏引擎 浅入浅出」4.1 Unity Shader和OpenGL Shader
[luogu_p4820] [national training team] stack [mathematics] [physics] [harmonic progression]
Cultural tourism and data collection | travel to Yunnan in an artistic way