# C語言筆記 ## 筆記傳送門 * [關鍵字筆記](https://hackmd.io/wkJEDjCGTTWV-IjvEzXjYA?view) * [函式筆記](https://hackmd.io/HC69PJDBT5KLd-LthrD14Q?view) * [陣列筆記](https://hackmd.io/uyU7KciRRp2rnZngbA5NoQ?view) * [指標筆記](https://hackmd.io/H6tpMXfpSq-MdZiL1wVNRg?view) * [字串筆記](https://hackmd.io/jIwQLyodSjamUksBY0JbhQ?view) ## 邏輯運算子 | and | or | not | xor | | --- |:----:| --- |:---:| | && | \|\| | ! | ^ | ## 關係運算子 ![](https://i.imgur.com/pqw9Yp9.png) ## 位元運算子 ![](https://i.imgur.com/ojEebIz.png) ## 資料型態(data type) | Type | Bits Width | Range | | ------------- | ---------- |:----------------------------:| | char | 1 Bytes | -128~127 | | int | 4 Bytes | -2,147,483,648~2,147,486,647 | | unsigned int | 4 Bytes | 0~4,294,967,295 | | long long int | 8 Bytes | -2^63 ~ 2^63-1 | | bool | 1 Bit | True(1) or False(0) | | float | 4 Bytes | 1.17\*10^-38 ~3.34\*10^38 | | double | 8 Bytes | 2.22\*10^-308 ~1.79\*10^308 | ## 指示詞(#) ### define >可放==數值,運算式,簡單函式 >>e.g. >>#define pi 3.14159 >>#define Add(x,y) x+y ### 跳過錯誤 >#pragma warning(disable:4996) ## 格式指定詞(Format Specifier) | 資料型態 | 格式指定詞 | |:-------------:|:----------:| | char | %c | | string | %s | | int | %d or %i | | long long int | %lld | | float | %f | | pointer | %p | | hexadecimal | %x | ### 與printf搭配 >==%(n)d== 預留n位放數字 不滿以空格代替 >==%.(n)f== 顯示到小數點後n位 被捨去的數會四捨五入