0%

C primer plus

++i with i++

1
2
3
4
5
6
7
8
9
10
11
12
#include<stdio.h>
int main ()
{
int a = 1 , b = 1 ;
int a1 ,b1 ;
a1 = a++;
b1 = ++b;
printf("a a1 b b1 \n");
printf("%1d %2d %1d %2d\n",a,a1,b,b1);

return 0 ;
}
1
2
a a1 b b1 
2 1 2 2

When n++ is part of an expression, you can think of it as meaning “use n ; then increment it.” On the other hand, ++n means “increment n ; then use it.”

C primer plus

P104

no ; after while and some ; in while

1
2
3
4
5
while(True)
{
line1;
line2;
}

p105

pow(a,b) = a**b //#include<math.h>

p110

int /int = int ;

float/float = float ;

float/int = float ;

int/float = float ;

C primer plus

P90

大部分C函数都有一个返回值
printf()函数也有一个返回值,它返回打印字符的个数。如果有输出错误, printf()则返回一个负值(printf()的旧版本会返回不同的值)。
printf()的返回值是其打印输出功能的附带用途,通常很少用到,但在检查输出错误时可能会用到(如,在写入文件时很常用)。如果一张已满的CD或DVD拒绝写入时,程序应该采取相应的行动,例如终端蜂鸣30秒。

p92

如果用scanf()读取基本变量类型的值,在变量名前加上一个&;
如果用scanf()把字符串读入字符数组中,不要使用&。

C primer plus

p81-p85

Although I think I can’t remember so much.

printf

image-20210113134259235

image-20210113134319669

C primer plus

p66

something in ‘ ‘ is a character(一个字符)

or something in “ “is a string(一个字符串)

C primer plus

p51

there are some differences between C and python
for example “ and ‘

something in “ “ is strings.

如果要把一个字符常量初始化为字母 A,不必背下 ASCII 码,用计算机语言很容易做到。通过以下初始化把字母A赋给grade即可:
char grade = ‘A’;
在C语言中,用单引号括起来的单个字符被称为字符常量(character constant)。编译器一发现’A’,就会将其转换成相应的代码值。单引号必不可少。下面还有一些其他的例子:
char broiled; /* 声明一个char类型的变量 /
broiled = ‘T’; /
为其赋值,正确 /
broiled = T; /
错误!此时T是一个变量 /
broiled = “T”; /
错误!此时”T”是一个字符串 /
如上所示,如果省略单引号,编译器认为T是一个变量名;如果把T用双引号括起来,编译器则认为”T”是一个字符串。字符串的内容将在第4章中介绍。
char grade = 65; /
对于ASCII,这样做没问题,但这是一种不好的编程风格 */在本例中,虽然65是int类型,但是它在char类型能表示的范围内,所以将其赋值给grade没问题。由于65是字母A对应的ASCII码,因此本例是把A赋给grade。注意,能这样做的前提是系统使用ASCII码。其实,用’A’代替65才是较为妥当的做法,这样在任何系统中都不会出问题。因此,最好使用字符常量,而不是数字代码值。

本来’B’对应的数值66储存在32位的存储单元中,现在却可以储存在8位的存储单元中(grade)。利用字符常量的这种特性,可以定义一个字符常量’FATE’,即把4个独立的8位ASCII码储存在一个32位存储单元中。如果把这样的字符常量赋给char类型变量grade,只有最后8位有效。因此,grade的值是’E’。

website

update // friends ,about,the icon of tag and the heart icon

C primer plus

p27

如果遗漏 main()函数中的 return 语句,程序在运行至最外面的右花括号(})时会返回0。因此,可以省略main()函数末尾的return语句。但是,不要在其他有返回值的函数中漏掉它。

p31

这里要注意,何时执行 butler()函数取决于它在 main()中被调用的位置,而不是 butler()的定义在文件中的位置。例如,把 butler()函数的定义放在 main()定义之前,不会改变程序的执行顺序, butler()函数仍然在两次printf()调用之间被调用。记住,无论main()在程序文件处于什么位置,所有的C程序都从main()开始执行。但是,C的惯例是把main()放在开头,因为它提供了程序的基本框架。
C标准建议,要为程序中用到的所有函数提供函数原型。标准include文件(包含文件)为标准库函数提供可函数原型。例如,在C标准中,stdio.h文件包含了printf()的函数原型。

p32

编译器另一个常见的毛病是,报错的位置比真正的错误位置滞后一行。例如,编译器在编译下一行时才会发现上一行缺少分号。因此,如果编译器报错某行缺少分号,请检查上一行。

How to set this website

hexo and next

hexo

My friend tell me that it is easy and I can “开箱即用”(use it fastly after I install it).
In this part,this zhihu helps me a lot.It teaches me how to deploy the ssh for github by git ,how to init hexo and how to set up domain name with my github pages.

https://zhuanlan.zhihu.com/p/26625249

next

The themes “next” on github gets the 15k stars and it has four “skins”and the “landscapes” is so brief which is difficult for me to change it to the pretty appearance in my mind.
In this part, I search so many informations on google.com and I find so many same article “洗稿,抄袭” on CSDN,”博客园”and so on. Because of my low level, I can’t understand the official document. I read nearly all the infomation in the last five months,but there are still a lot of wrong answers and most of them is out of data.So It took me all day to finish it.
This is a website which makes my program crash and I put it here.

https://blog.csdn.net/as480133937/article/details/100138838

Others

I buy the domain by Tecent Cloud and buy the oss on AliCloud.I put my pictures on oss and use the Resolution Service by github.

Something not important

The tag of the website is

hhyicon
And I plan to learn C++ after put this website ,but I finish it after 00:00.
That’s all.

Vs code

I try to use Visual Studio Code about two months ago ,because Pycharm can’t satisfy the needs of some kinds of languages or wsl. This time I only need to attend some plug-in.

g++

Because g++ is in linux and the laptop I used is windows , I had to search the solution on Google .But when I try to do as the Tutorial ,the browser always said that “ 将您重定向的次数过多“ .I almost try all solutions on the google, but it makes no sense.

At last I download it on my mobile-phone and send it to my laptop.

Hello,world!

After all, I copy a helloworld.cpp,like that

1
2
3
4
5
6
7
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, world!" << endl;
return 0;
}

I call g++ test1.cpp and .\test1 get the right answer Hello,world!

20210104_helloworld

The last day of the exam and I can go back to Tianjin soon.

PS: This website which uses hexo is set up by the help of jjc and zhihu

thanks!