
C C++
文章平均质量分 65
C C++相关
小白笑苍
沉默是一种生活方式。
展开
-
C语言 printf函数缓冲机制
printf函数使用了缓冲机制。当我们调用printf时,输出通常不会立即显示在屏幕上,而是先存储在一个缓冲区中。这是为了提高I/O操作的效率。stdio库维护了一个缓冲区。当缓冲区满了,或者在特定条件下,缓冲区的内容会被刷新(flush)到实际的输出设备(如屏幕)。原创 2024-07-09 13:35:52 · 628 阅读 · 0 评论 -
popen底层实现原理
popen是C语言标准库中的一个函数,它提供了一种方便的方式来执行外部命令并与之进行通信。原创 2024-05-27 10:58:16 · 573 阅读 · 0 评论 -
C语言getopt()函数
【代码】C语言getopt()函数。原创 2023-03-14 16:51:11 · 1373 阅读 · 0 评论 -
What are the differences between UTF-8, UTF-16, and UTF-32?
Answer1UTF-8 has an advantage in the case where ASCII characters represent the majority of characters in a block of text, because UTF-8 encodes these into 8 bits (like ASCII). It is also advantageous...原创 2020-05-06 10:45:55 · 235 阅读 · 0 评论 -
about the C++ object model
## plain object## Alignmentalign with the longest one, such as 4 bytes alignment## Inheritance## object in objectit is same with the Inheritance.## virtual function adde...原创 2020-04-14 10:17:52 · 205 阅读 · 0 评论 -
关于C++11 的右值引用
右值引用:追要是分移动语义+完美转发。目的是减少赋值操作中的新建内存再copy的造作,直接复用右值已经申请的内存空间和里面对应的内容。本质上是添加move constructor 和 move assignment constructor,move函数将入参类型static_cast为T&&,调用构造函数时就不会去调用copy constructor和copy assignmen...原创 2020-04-02 11:08:17 · 197 阅读 · 0 评论 -
c++中函数声明的后面加=0
纯虚函数是在声明虚函数时被“初始化”为0的函数。声明纯虚函数的一般形式是 virtual 函数类型 函数名 (参数表列) =0; 注意: ①纯虚函数没有函数体; ②最后面的“=0”并不表示函数返回值为0,它只起形式上的作用,告诉编译系统“这是纯虚函数”; ③这是一个声明语句,最后应有分号。纯虚函数只有函数的名字而不具备函数的功能,不能被调用。它只是通知编译系...原创 2018-09-10 16:11:58 · 11237 阅读 · 1 评论 -
freeNOS代码走读杂记
最近在看github上一个微os的代码,freeNOS.走读的过程中顺便记一下学习的点枚举用位偏移定义来提高效率/** * Memory access flags. */typedef enum Access{ None = 0, Readable = 1 << 0, Writable = 1 << ...原创 2018-09-13 09:36:24 · 2583 阅读 · 0 评论 -
JSON库代码杂记1
最近在看github上一个JSON库教程.记一下临时的一些点tutorial01头文件用宏加入include guard,防止重复声明#ifndef LEPTJSON_H__#define LEPTJSON_H__/* ... */#endif /* LEPTJSON_H__ */没有硬编码,全部枚举化,用了两次数据结构抽象来提高代码的复用性,健壮性typed...原创 2018-09-07 16:01:07 · 150 阅读 · 0 评论 -
关于printf 信息从缓存到标准输出和后续代码执行的先后顺序的一个问题
背景今天一个同事在定位栈溢出的问题的时候,在问题函数的入口处加了一个printf打印函数来协助定位问题原因(当时不知道是stack overflow),发现printf没有将信息打印到stdout程序就dump了。我这边就在想一个问题,printf的信息从buffer到stdout的时间和后续代码执行的一个先后顺序到底是什么呢?一些结果查了一下,关于printf从buffer输出到stdo...原创 2019-01-28 17:03:38 · 343 阅读 · 0 评论 -
The C++ compilation process
The C++ compilation processCompiling a source code file in C++ is a four-step process. For example, if you have a C++ source code file named prog1.cpp and you execute the compile command g++ -Wall...原创 2019-07-08 15:26:33 · 432 阅读 · 0 评论 -
code blocks 安装编译器和gdb
版权声明:本文为博主原创文章,若转载请附上原地址~ https://blog.youkuaiyun.com/sinat_27088253/article/details/52137855 </div> ...转载 2019-06-27 17:01:56 · 2063 阅读 · 0 评论 -
What is span<t> in c++ and when should I use it
stack overflow answer原创 2019-07-03 15:18:18 · 240 阅读 · 0 评论 -
C++ using declaration
1using can be used to introduce namespace members into other namespaces and block scopes, or introduce base class members into derived class definitions.introduce namespace#include<iostream>...原创 2019-07-12 15:39:46 · 439 阅读 · 0 评论 -
C++ 引用占用内存?
一、引用的本质是什么说到引用,一般C++的教材中都是这么定义的:1,引用就是一个对象的别名。2,引用不是值不占内存空间。3,引用必须在定义时赋值,将变量与引用绑定。那你有没有想过,上面的定义正确吗?编译器是如何解释引用的?这里先给出引用的本质定义,后面我们再进一步论证。1,引用实际是通过指针实现的。2,引用是一个常量指针。3,引用在内存中占4个字节。4...转载 2019-08-19 15:18:01 · 5371 阅读 · 8 评论 -
How to output the message when using the function 'printf'
The stdout stream is buffered,so only when it meets a new line or told to display can it show what you wanna show. So if you want to display your print whenever you execute the related code,you can us原创 2017-10-27 16:57:46 · 240 阅读 · 0 评论