C语言笔记
文章平均质量分 65
养牛青年
一只平凡且快乐的程序猿!
展开
-
用printf实时刷新终端打印出的数据
前言有时,对于终端输出的数据,我们希望能够实时刷新。比如:输出温度、时间、坐标等随时变化的信息,我们更希望仅仅刷新数据本身,而不是一行一行的不断输出打印信息。一、printf实时刷新二、使用步骤1.引入库代码如下(示例):import numpy as npimport pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsimport warningswarnings.filterwarnings('ign原创 2021-09-15 21:36:12 · 3824 阅读 · 0 评论 -
free(ptr) 之后
前言free(ptr)之后,有时会是血雨腥风!请看代码,如下:#include <stdio.h>#include <stdlib.h>#define OK 0#define ERROR 1int main(void){ //动态分配内存 int *num = (int *)malloc(sizeof(int)); if (NULL == num) { return ERROR; } //在分配的内存中写入数原创 2021-06-25 23:02:55 · 526 阅读 · 0 评论 -
C语言的数组长度能用变量指定吗?
疑问:C语言的数组长度就真不能用变量指定吗?回答:不一定。一、背景简介C89/C90:C89即ANSI C,ANSI:美国国家标准学会(American Natinal Standards Institute)C90即ISO C,ISO:国际标准化组织(International Standard Organization)ANSI C 和 ISO C是完全相同的标准,ANSI C最终版本于1989年被批准,故叫C89。ISO C最终版本于1990年被批准,故叫C90。C99:199原创 2021-04-23 07:51:46 · 20632 阅读 · 2 评论 -
getchar,putchar,EOF
前言本文将以简单的代码介绍getchar(), putchar() 和 EOF 。定义getchar()“getchar() reads the next input character from a text stream and returns that as its value”“the characters normally come from the keyboard”还来源于文本,这个后面再讨论。putchar()“putchar() prints a chara原创 2020-09-20 17:15:12 · 396 阅读 · 0 评论 -
register关键字的使用
前言本文用简单代码实验介绍static关键字的使用。上代码#include <stdio.h>int main(void){ int i; int tmp = 0; for (i=1; i<5; i++) { tmp++; printf("tmp = %d\n", tmp); printf("&i = %d\n\n", &i); }}/*运行结果:tmp = 1&i = 6422296tmp = 2&.原创 2020-09-04 00:57:18 · 1694 阅读 · 0 评论 -
auto 关键字的使用
auto 关键字的使用本文用简单代码实验介绍了auto关键字的使用。上代码#include <stdio.h>int main(void){ int i; int num = 2; for (i=0; i<3; i++) { printf("num = %d\n", num); num++; { auto int num = 1; printf("the internal block num = %d\n", num); num++;原创 2020-09-03 00:15:18 · 316 阅读 · 0 评论