Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> การเขียนโปรแกรม C

สัญลักษณ์พิเศษ (Special Symbols) ในภาษา C คืออะไร


คำอธิบาย

ในภาษาโปรแกรม C สัญลักษณ์พิเศษมีความหมายเฉพาะและไม่สามารถนำไปใช้เพื่อวัตถุประสงค์อื่นได้ สัญลักษณ์พิเศษที่ใช้ใน C มีดังนี้:

[] () {}, ; * = #

ความหมายของสัญลักษณ์หลัก

  • Brackets [] - ใช้สำหรับอ้างอิงอิลิเมนต์ของอาร์เรย์ แสดงดัชนีเดี่ยวหรือหลายมิติ
  • Parentheses () - ใช้เรียกฟังก์ชันและระบุพารามิเตอร์
  • Braces {} - กำหนดขอบเขตบล็อกโค้ดที่มีคำสั่งมากกว่า 1 คำสั่ง
  • Comma (,) - แยกคำสั่งหรือพารามิเตอร์หลายตัว เช่น ในการเรียกฟังก์ชัน
  • Colon (:) - ใช้ในการเริ่มต้นรายการ (initialization list) หรือ label
  • Semicolon (;) - ตัวจบคำสั่ง (Statement terminator) ทุกคำสั่งต้องลงท้ายด้วย semicolon
  • Asterisk (*) - ใช้ประกาศตัวแปร Pointer
  • Assignment operator (=) - ใช้กำหนดค่า
  • Pre-processor (#) - ใช้สำหรับคำสั่งก่อนคอมไพล์ เช่น #include, #define

ตารางสัญลักษณ์พิเศษและความหมาย

สัญลักษณ์ ความหมาย
~Tilde
!Exclamation mark
#Number sign / Hash
$Dollar sign
%Percent sign
^Caret
&Ampersand
*Asterisk
(Left parenthesis
)Right parenthesis
_Underscore
+Plus sign
,Comma
.Period / Dot
/Slash
|Vertical bar / Pipe
\Backslash
`Backtick / Grave accent
-Minus sign / Hyphen
=Equal sign
<Less than / Left angle bracket
>Greater than / Right angle bracket
?Question mark
{Left brace
}Right brace
[Left bracket
]Right bracket
:Colon
"Quotation mark
;Semicolon