CS50 Lesson 4 — tutorial notes

Maggie
2 min readAug 23, 2021

23–Aug-2021

With reference: https://www.youtube.com/watch?v=SFyPaFCmztI&list=PLFoKfo4MKOCY65YfyGVr0EZp4FNA4rv7D&index=9

配信: https://www.youtube.com/watch?v=fBRkzs2Z6t4&t=1s

這個月發生了很多事情, 但我最想說得應該是我的推去了參加apex大會, 由一開始在練習時很順利到後期的跌跌撞撞, 我也想到了我一路以來的學習經歷。我也很常剛開始學甚麼都很順利的樣子, 可到了中後期的時候, 需要練習的時候我總是會很惰怠﹑不願意多花心力, 可能是怕了我盡力後的失敗會證實了我自己能力不夠的事實。可是看到他們天天練習, 到後來在最後一場嬴得勝利的一瞬間我覺得好像獲得了勇氣一樣。希望我也會繼續努力學下去, 能像他們一樣獲得自己想得到的新技能。

Hexadecimal
one kind of presentation of values, like binary and decimal
but its presentation really looks like decimal sometimes, so will use 0x as suffix to show that it is hexadecimal
Example: RGB (red green blue)
Hexadecimal is very convenient to convert to binary because 4th unit of binary would be equal to 1 unit of hexadecimal number.

Data structure
typedef struct{int name; string name;} person ← as long as i rmb?
typedef
1. shorthand or rewritten name for data types
2. define a type in the normal way, then alias it to sth else

rewrite name:
typedef <old name> <new name>
typedef unsigned char byte; ← This one I don’t understand
typedef char* string;

photo a: redefine structure name from car to car_t
could finish it in one line instead of adding 2 lines
originally need to def the struct first (if you didn’t rename the structure in photo a)
now only need to tell the name

Is it necessary to rename for the struct first? ←no, you could simply name it like photo a // name it with typedef without naming it after struct
or just struct without the typedef would still work the same? yes
if you use typedef, the declaration could be shorten like the last photo in the above.

--

--