<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>C on Cylon&#39;s Collection</title>
    <link>https://www.oomkill.com/tags/c/</link>
    <description>Recent content in C on Cylon&#39;s Collection</description>
    <generator>Hugo -- 0.125.7</generator>
    <language>zh</language>
    <lastBuildDate>Mon, 01 Jan 0001 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://www.oomkill.com/tags/c/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>ch0 ide</title>
      <link>https://www.oomkill.com/ch0-ide/</link>
      <pubDate>Wed, 28 Sep 2022 00:00:00 +0000</pubDate>
      <guid>https://www.oomkill.com/ch0-ide/</guid>
      <description>Visual Studio使用 离线安装包 在页面 [4] 下载安装引导命令，下载完成后使用命令（对于C++来说）
bat 1 vs_Professional.exe --layout ‪1111 --add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --lang en-US zh-CN 随后会触发下载，等待下载完成后，在 --layout 指定的目录上点击 vs_setup 开始离线安装。
Note: 对于完全脱离C盘安装可以使用下面的脚本，更改变量为要安装的路径
bat 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 :: 关闭终端回显 @echo off SET ROOT_PATH=D:\Program Files\Microsoft Visual Studio SET X86_PATH=%ROOT_PATH%\Program Files (x86) SET X86_VS_PATH=%X86_PATH%\Microsoft Visual Studio SET X86_SDK_PATH=%X86_PATH%\Microsoft SDKs SET X86_KITS_PATH=%X86_PATH%\Windows Kits SET X86_AV_PATH=%X86_PATH%\Application Verifier SET X64_PATH=%ROOT_PATH%\Program Files rem SET X64_VS_PATH=%X64_PATH%\Microsoft Visual Studio SET X64_AV_PATH=%X64_PATH%\Application Verifier SET X64_SQL_PATH=%X64_PATH%\Microsoft SQL Server SET PD_PATH=%ROOT_PATH%\ProgramData SET PD_VS_PATH=%PD_PATH%\Microsoft\VisualStudio SET PD_PC_PATH=%PD_PATH%\Package Cache @echo =======link directory to %ROOT_PATH%=======: SET S_X86_SKD_PATH=C:\Program Files (x86)\Microsoft SDKs SET S_X86_VS_PATH=C:\Program Files (x86)\Microsoft Visual Studio SET S_X86_KITS_PATH=C:\Program Files (x86)\Windows Kits SET S_X86_AV_PATH=C:\Program Files (x86)\Application Verifier SET S_X64_AV_PATH=C:\Program Files\Application Verifier SET S_X64_SQL_PATH=C:\Program Files\Microsoft SQL Server SET S_PD_VS_PATH=C:\ProgramData\Microsoft\VisualStudio SET S_PD_PC_PATH=C:\ProgramData\Package Cache pause @echo =======setting visual studio environment=======: @echo =======check directory exist=======: if not exist %ROOT_PATH% ( echo &amp;#34;%ROOT_PATH%目录不存在，已创建该目录！&amp;#34; md &amp;#34;%ROOT_PATH%&amp;#34; ) if not exist %X86_PATH% ( echo &amp;#34;%X86_PATH%目录不存在，已创建该目录！&amp;#34; md &amp;#34;%X86_PATH%&amp;#34; ) if not exist %X86_VS_PATH% ( echo &amp;#34;%X86_VS_PATH%目录不存在，已创建该目录！&amp;#34; md &amp;#34;%X86_VS_PATH%&amp;#34; ) if not exist %X86_SDK_PATH% ( echo &amp;#34;%X86_SDK_PATH%目录不存在，已创建该目录！&amp;#34; md &amp;#34;%X86_SDK_PATH%&amp;#34; ) if not exist %X86_KITS_PATH% ( echo &amp;#34;%X86_KITS_PATH%目录不存在，已创建该目录！&amp;#34; md &amp;#34;%X86_KITS_PATH%&amp;#34; ) if not exist %X86_AV_PATH% ( echo &amp;#34;%X86_AV_PATH%目录不存在，已创建该目录！&amp;#34; md &amp;#34;%X86_AV_PATH%&amp;#34; ) if not exist %X64_PATH% ( echo &amp;#34;%X64_PATH%目录不存在，已创建该目录！&amp;#34; md &amp;#34;%X64_PATH%&amp;#34; ) if not exist %X64_AV_PATH% ( echo &amp;#34;%X64_AV_PATH%目录不存在，已创建该目录！&amp;#34; md &amp;#34;%X64_AV_PATH%&amp;#34; ) if not exist %X64_SQL_PATH% ( echo &amp;#34;%X64_SQL_PATH%目录不存在，已创建该目录！&amp;#34; md &amp;#34;%X64_SQL_PATH%&amp;#34; ) if not exist %PD_PATH% ( echo &amp;#34;%PD_PATH%目录不存在，已创建该目录！&amp;#34; md &amp;#34;%PD_PATH%&amp;#34; ) if not exist %PD_VS_PATH% ( echo &amp;#34;%PD_VS_PATH%目录不存在，已创建该目录！&amp;#34; md &amp;#34;%PD_VS_PATH%&amp;#34; ) if not exist %PD_PC_PATH% ( echo &amp;#34;%PD_PC_PATH%目录不存在，已创建该目录！&amp;#34; md &amp;#34;%PD_PC_PATH%&amp;#34; ) @echo =======link directory to %ROOT_PATH%=======: :: x86 link mklink /j &amp;#34;%S_X86_SKD_PATH%&amp;#34; &amp;#34;%X86_SDK_PATH%&amp;#34; mklink /j &amp;#34;%S_X86_VS_PATH%&amp;#34; &amp;#34;%X86_VS_PATH%&amp;#34; mklink /j &amp;#34;%S_X86_KITS_PATH%&amp;#34; &amp;#34;%X86_KITS_PATH%&amp;#34; mklink /j &amp;#34;%S_X86_AV_PATH%&amp;#34; &amp;#34;%X86_AV_PATH%&amp;#34; :: x64 link mklink /j &amp;#34;%S_X64_AV_PATH%&amp;#34; &amp;#34;%X64_AV_PATH%&amp;#34; mklink /j &amp;#34;%S_X64_SQL_PATH%&amp;#34; &amp;#34;%X64_SQL_PATH%&amp;#34; :: ProgramData link mklink /j &amp;#34;%S_PD_VS_PATH%&amp;#34; &amp;#34;%PD_VS_PATH%&amp;#34; mklink /j &amp;#34;%S_PD_PC_PATH%&amp;#34; &amp;#34;%PD_PC_PATH%&amp;#34; pause VS快捷键 快捷键 含义 Ctrl + k,Ctrl + f 自动格式化代码 Ctrl + k,Ctrl + c 注释代码 Ctrl + k,Ctrl + u 取消注释代码 F9 设置断点 F5 调试运行 Ctrl + F5 不调试运行 Ctrl + Shift + b 编译，不运行 F10 next调试 F11 step调试 调试 添加行号：工具&amp;ndash;》选项 &amp;ndash;》文本编辑器&amp;ndash;》C/C++ &amp;ndash;》行号</description>
    </item>
    <item>
      <title>ch01 变量和数据类型</title>
      <link>https://www.oomkill.com/ch01-parmeter-and-data-structrue/</link>
      <pubDate>Wed, 28 Sep 2022 00:00:00 +0000</pubDate>
      <guid>https://www.oomkill.com/ch01-parmeter-and-data-structrue/</guid>
      <description>C语言关键字 [1] ==C语言有32个关键字==
auto：定义自动变量，主要是声明变量的生存周期 break, continue : break 语句在遇到最内层循环时立即终止。还用于终止 switch 语句。 case, switch, default：使用 switch 和 case 语句声明一个switch分支 char：用于声明character 类型的变量 const：声明常量 do&amp;hellip;while： double： double-precision 浮点数变量类型 float：single-precision 浮点数的变量类型 if, else：声明if/else 条件判断 enum：用于声明枚举类型 extern：关键字声明变量或函数在其声明的文件之外具有外部链接。 for：C 语言的三种循环之一，for循环 goto： 用于将程序的控制权转移到指定的标签 int：声明 integer 类型的变量 short, long, signed, unsigned：是类型修饰符，它们改变基本数据类型的含义以产生新类型。 short int： -32768 to 32767 long int： -2147483648 to 214743648 signed int： -32768 to 32767 unsigned int： 0 to 65535 return： 终止函数并返回值 sizeof：评估变量或常量的大小 register：创建比普通变量快得多的寄存器变量。 static：创建一个静态变量。静态变量的值持续到程序结束。 struct：用于声明结构体。结构体可以包含不同类型的变量。 typedef：用于将类型与标识符显式关联。 union：用于将不同类型的变量分组在一个名称下。 void：没有任何意义，函数修饰为没有返回值，参数修饰为没有参数 volatile：提醒编译器它后面所定义的变量随时都有可能改变 C语言控制语句 ==C语言有9种控制语句== (control statements)</description>
    </item>
    <item>
      <title>ch02 格式化与流程控制</title>
      <link>https://www.oomkill.com/ch02-control-statements-and-format/</link>
      <pubDate>Wed, 28 Sep 2022 00:00:00 +0000</pubDate>
      <guid>https://www.oomkill.com/ch02-control-statements-and-format/</guid>
      <description>格式化 printf printf() 用于打印消息以及变量的值。
c 1 2 3 4 5 6 7 8 #include&amp;lt;stdio.h&amp;gt; int main() { int a = 24; printf(&amp;#34;Welcome! \n&amp;#34;); printf(&amp;#34;The value of a : %d&amp;#34;,a); getchar(); return 0; } sprintf sprintf() 不打印字符串，是将字符值和格式化结构一并存储在一个数组中。
c 1 2 3 4 5 6 7 8 9 10 11 12 13 int main() { char buffer[50]; int a = 10, b = 20, c; c = a + b; sprintf(buffer, &amp;#34;Sum of %d and %d is %d&amp;#34;, a, b, c); // The string &amp;#34;sum of 10 and 20 is 30&amp;#34; is stored // into buffer instead of printing on stdout printf(&amp;#34;%s&amp;#34;, buffer); return 0; } scanf 从标准输入读取用户输入的</description>
    </item>
    <item>
      <title>ch03 数组</title>
      <link>https://www.oomkill.com/ch03-array/</link>
      <pubDate>Wed, 28 Sep 2022 00:00:00 +0000</pubDate>
      <guid>https://www.oomkill.com/ch03-array/</guid>
      <description>Array [1] 数组是由单个元素组成的一组数据类型的变量 数组的元素存储在连续的内存位置 声明数组时应提及数组的大小 数组的计数从0开始 数组为一位数组与多维数组 数组首元素的地址与数组地址相同 数组包含 int, float, char, double 数据类型 Declaration and Initialization 表达式 说明 int my_array1[20]; 指定大小，来声明一个有20个元素的int数组 char my_array2[5]; 指定大小，来声明一个有5个元素的char数组 int my_array[] = {100, 200, 300, 400, 500} 声明时初始化一个数组（编译器自动求数组元素个数） int my_array1[5] = {100, 200, 300, 400, 500}; 声明时初始化 int my_array2[5] = {100, 200, 300}; 声明时初始化（剩余未初始化的元素，默认 0 值） int my_array2[5] = {0}; 声明时初始化（声明一个全0值的数组） int arr[10]; arr[0] = 5;arr[1] = 6;arr[2] = 7; 声明数组并初始化值（这种方法为初始化部分的默认值为随机数） char str[] = &amp;ldquo;zhangsan&amp;rdquo; 声明一个字符串（字符串是一个char类型数组） Advantages and Disadvantages 缺点**：大小限制**：声明（定义）后是固定的大小，不能通过运行时改变其大小</description>
    </item>
    <item>
      <title>ch04 函数</title>
      <link>https://www.oomkill.com/ch04-function/</link>
      <pubDate>Wed, 28 Sep 2022 00:00:00 +0000</pubDate>
      <guid>https://www.oomkill.com/ch04-function/</guid>
      <description>concept [1] 函数 (function) 是执行任务的语句块。
函数的作用：
提高代码的可重用性并减少冗余 代码模块化 代码易读性 使代码模块化 函数的分类 C语言中有两种类型的函数：
标准库函数：C中的内置函数，在头文件中定义 #include &amp;lt;stdio.h&amp;gt; 用户自定义函数：用户自定义的函数 #include &amp;quot;stdio.h&amp;quot; 函数三部曲 C语言中函数分为三个方面，声明(declaration)，定义(defining)，调用(calling)
声明 声明是让编译器知道函数的名称、参数信息、参数的返回值的类型。
c 1 (type) function_name({type args...}); 隐式声明(implicit) ：当在main之后定义的函数而未声明，默认编译器会做隐式声明。
ISO/IEC 9899:1990 中 关于函数声明的部分：
函数在调用前必须有一个可用的声明，如果没有被声明，则该函数默认被隐式声明，该隐式声明没有参数，返回值为int [2]
定义 C中函数定义的语法如下
c 1 2 3 4 return_type function_name(arg1, arg2, ... argn) { function body // 函数中要处理任务的逻辑 } return_type：函数返回值的数据类型 function_name：函数名 arg1, arg2, &amp;hellip;argn：参数列表（可选），定义传递给函数的数据类型、顺序和参数的数量。 function body：调用函数时任务处理和执行的语句 调用 调用是指要由编译器执行的函数，可以在任何部分调用
虚函数void 如果函数没有返回值，则使用关键字 void，主要用于两个方面：
打印具体信息供用户阅读的函数 引用参数，函数通常不是用于返回一个内容，而是修改引用参数的，无需返回值 void 关键字使用注意：
void仅用于限定函数返回值，函数参数，不可以修饰变量，因为无法对无类型的变量分配指针</description>
    </item>
    <item>
      <title>ch05 指针</title>
      <link>https://www.oomkill.com/ch05-pointer/</link>
      <pubDate>Wed, 28 Sep 2022 00:00:00 +0000</pubDate>
      <guid>https://www.oomkill.com/ch05-pointer/</guid>
      <description>指针 指针声明 [1] 指针/指针变量 (pointer) 是用于存储地址的变量
使用 &amp;amp; 运算符 来访问变量的地址。例如
c 1 2 3 4 5 6 7 #include &amp;lt;stdio.h&amp;gt; void main() { int a = 100; printf(&amp;#34;%x&amp;#34;, &amp;amp;a); } 输出结果为 16进制的内存地址
c 1 61fe1c 使用地址运算符 * 可以从变量地址中获取变量的值，这个行为被称为间接引用/解引用(indirection/dereferencing)。例如：
c 1 2 3 4 5 6 7 8 9 #include &amp;lt;stdio.h&amp;gt; void main() { int a = 100; printf(&amp;#34;%d&amp;#34;, *(&amp;amp;a)); // 也可以写为，因为*与&amp;amp;优先级相同，从右到左的顺序，所以有没有()意思是相同的 printf(&amp;#34;%d&amp;#34;, *&amp;amp;a); } 输出结果为 100
指针变量 指针变量是指存储一个变量的地址的变量，可以使用符号 * 来修饰变量，定义语法为：</description>
    </item>
    <item>
      <title>ch06 内存布局</title>
      <link>https://www.oomkill.com/ch06-memory-layout/</link>
      <pubDate>Wed, 28 Sep 2022 00:00:00 +0000</pubDate>
      <guid>https://www.oomkill.com/ch06-memory-layout/</guid>
      <description>Overview 在编写程序时包含任意指令如，已初始化和未初始化数据，局部变量，函数等都是用于动态分配内存的指令。当程序编译后（默认生成 x.out 文件）这是一个可执行的链接文件( Executable and linking format)。在执行时这些不组织成几部分，包含不同的内存分段 (segments)
ELF：这是系统中标准二进制格式，其一些功能包含，动态链接，动态加载，对程序运行时控制。
可以使用 size {ELF_file} 查看被分配的每个段的大小（Linux操作系统）；
dec 列给出的是这个程序 text + data + bss 段的总大小，用十进制表示 text 段是存储可执行命令的段 data 段包含所有初始化数据，全局与静态变量 BSS 段包含未初始化数据 bash 1 2 3 $ size 1 text data bss dec hex filename 1843 584 8 2435 983 1 Memory Layout in C [1] 在C语言中内存布局模型包含六个部分
命令行参数 (Command Line Arguments) 栈 (Stack) 堆 (Heap) 未初始化数据段 (Uninitialized Data Segment BSS) 已初始化数据段 (Initialized Data Segment) 文本/代码段 (Text/Code Segment) 这6部分结构可以再划分为两种类型：</description>
    </item>
    <item>
      <title>ch07 复合类型</title>
      <link>https://www.oomkill.com/ch07-composite-type/</link>
      <pubDate>Wed, 28 Sep 2022 00:00:00 +0000</pubDate>
      <guid>https://www.oomkill.com/ch07-composite-type/</guid>
      <description>Overview C语言中复合类型 (composite type) 是指用户自定义类型，通常由多种元素组成的类型，其元素被紧密存储在内存中。C语言常见的复合类型有：
数组 字符串 结构体 联合类型 结构体 [1] 结构体 (structure) 是指用户定义的数据类型，允许将不同类型的多个元素组合在一起，来创建出更复杂的数据类型，类似于数组，但又区别于数组，数组只能保存同类型的元素，而结构体可以保存不同类型的元素。
定义 声明结构体的语法如下
c 1 2 3 4 5 6 struct structureName { dataType memberVariable1; datatype memberVariable2; ... } variable01, variable02...; 这里需要注意的一些地方：
struct是关键字，structureName定义的新数据类型，variable{}是作为使用 structureName 声明的新变量名 每个成员方法结尾都是 “;&amp;quot; 而不是逗号 ”,&amp;quot; 结构体不能递归 变量可以有多个 例如声明一个学生的结构体，而student是作为一个新的数据类型存在
c 1 2 3 4 5 6 struct student { char name[20]; int roll; char gender; }; Notes：在定义（创建）结构体变量前，结构体成员不会占用内存
声明 使用结构体声明变量
也可以一次性定义结构体和声明变量
c 1 2 3 4 5 6 7 8 9 10 11 12 13 struct student { char name[20]; int roll; char gender; } stu1,stu2; // 结构体名称可以省略 struct { char name[20]; int roll; char gender; } stu1,stu2; 赋值 在声明结构体后，student结构体只是自定义数据结构，要使用还需要进行初始化，或者赋值</description>
    </item>
    <item>
      <title>ch08 文件处理</title>
      <link>https://www.oomkill.com/ch08-file-handling/</link>
      <pubDate>Wed, 28 Sep 2022 00:00:00 +0000</pubDate>
      <guid>https://www.oomkill.com/ch08-file-handling/</guid>
      <description>文件类型 文件是指以字节的形式存储的数据源，使用C语言将文件数据以输出输出的形式处理叫做文件处理。
文件在C语言中以两种形式存在：
文本文件：文本文件是简单的文件类型，这些文件内容以 ASCII 字符格式存储信息。 二进制文件：二进制文件以 0 和 1 的二进制格式存储数据，不是人类可读的文件 文件指针 文件指针 (FILE) 是一种数据类型，是被定义在 stdio.h 中的一种结构体，包含了文件的一些信息
c 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 typedef struct { // fill/empty level of buffer int level; // File status flags unsigned flags; // File descripter char fd; // ungetc char if no buffer unsigned char hold; // buffer size int bsize; // data transfer buffer unsigned char *buffer; // Current active pointer unsigned char *curp; //Temporary file indicator unsigned istemp; //Used for validity checking short token; } FILE; // This is FILE object 文件指针通常被用于处理正在访问的文件，fopen() 是用于打开文件并返回文件的 FILE 指针，而后通过文件只恨进行I/O操作。fopen() 会发生下列事件：</description>
    </item>
    <item>
      <title>C程序编译错误记录</title>
      <link>https://www.oomkill.com/c-complie-record/</link>
      <pubDate>Tue, 02 Nov 2021 00:00:00 +0000</pubDate>
      <guid>https://www.oomkill.com/c-complie-record/</guid>
      <description>Question1: Similar to pause command in linux
text 1 read -n 1 Question2 read : Illegal option -n
原因为ubuntu 默认的是dash 不是 bash Reference
Question3: How to Compile C programing Language
text 1 gcc hello.c -o hello Question4: Segmentation fault (core dumped)
编译正常执行错误，在linux中使用 strace 查看具体报错。
Reference</description>
    </item>
  </channel>
</rss>
