2020.11 记录
C 语言: 用EOF代替回车作为终止输入的符号
EOF 知识链接:
What is EOF in the C programming language?
用EOF终止输入需要保证EOF在回车后输入, 否则EOF不会被识别到
1 | // 用EOF终止字符的输入 |
题目:
http://oj.kfcoding.com/contest/24/problem/6-1
答案:
1 |
|
C语言: 消除输出的最后一位空格
1 | printf("%c",8); |
上面这里是输出ASCII码为8的字符,这是一个Backspace控制符。于是可以往回消去一个字符。
PS: 经过验证, 该方法有效, 但是在学校的oj平台上无用, 且会被判定为未知字符.
Git & Github
How to clone all remote branches in Git?
VSCODE: 输出中文乱码解决方法
https://www.w3xue.com/exp/article/20203/80007.html
https://zhuanlan.zhihu.com/p/30127242)
C语言: strrev() function
strrev() function
It is used to reverse the given string expression.
1 | #include<stdio.h> |
1 | // output |
C语言: scanf输出输出一行包括空格的字符串
String Input and Output
Input function scanf()
can be used with %s format specifier to read a string input from the terminal. But there is one problem with scanf()
function, it terminates its input on the first white space it encounters. Therefore if you try to read an input string “Hello World” using scanf()
function, it will only read Hello and terminate after encountering white spaces.
However, C supports a format specification known as the edit set conversion code %[..] that can be used to read a line containing a variety of characters, including white spaces.
1 |
|
C语言: 动态分配数组(一维)
数组元素个数为变量
1 | int *a = NULL; // 声明数组头指针 |
C语言: 动态分配数组(二维)
1 |
|
C语言: Problem with scanf() when there is fgets()/gets()/scanf() after it
C语言: fgets函数的一些注意事项
1 | char *fgets(char *str, int n, FILE *stream); |
fets
函数中的第二个参数为字符串的允许输入个数, 实际上这个个数是要算上字符串的结尾‘\0’, 除去‘\0’, 有效输入字符为n-1
个.当fgets函数以换行符号作为最后的终止符, 如果当前输入的字符个数小于
n-1
, 那么换行符\n
也会作为输入字符记载到字符串中.