• How We Do It

    How We Do It

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sit amet nisl lectus, id sagittis metus.

  • Easy to Customize

    Easy to Customize

    Nunc sapien risus, molestie sit amet pretium a, rutrum a velit. Duis non mattis velit. In tempus suscipit sem, et consectetur.

  • Clean Design

    Clean Design

    Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam consequat risus et lectus aliquet egestas.

  • Works Everywhere

    Works Everywhere

    Nullam a massa ac arcu accumsan posuere. Donec vel nibh sit amet metus blandit rhoncus et vitae ipsum.

  • Web Development

    Web Development

    Suspendisse eleifend nulla in est euismod scelerisque. Etiam lacinia fermentum nunc id imperdiet.

  • Color Picker

    Color Picker

    Nullam tortor tellus, iaculis eu hendrerit ut, tincidunt et lorem. Etiam eleifend blandit orci.

แสดงบทความที่มีป้ายกำกับ B02.คำสั่งหมายเหตุ แสดงบทความทั้งหมด
แสดงบทความที่มีป้ายกำกับ B02.คำสั่งหมายเหตุ แสดงบทความทั้งหมด

B02.คำสั่งหมายเหตุ

การเขียนหมายเหตุ (comment) คือ ข้อความที่เขียนไว้ภายในโปรแกรม เพื่อใช้อธิบายโปรแกรม โดยตัวแปรโปรแกรมจะไม่แปลข้อความคำสั่งหมายเหตุให้เป็นภาษาเครื่อง

การเขียนข้อความสั่งหมายเหตุในโปรแกรมทำได้ 2 แบบ ได้แก่

1. //หมายเหตุ ใช้เครื่องหมาย // หน้าข้อความหมายเหตุ ใช้ได้กับหมายเหตุที่มีขนาดความยาวไม่เกิน 1 บรรทัด

ตัวอย่าง การเขียนแบบอธิบาย code ของแต่ละบรรทัด

//นำเข้า Header file ที่ชื่อว่า stdio.h
#include  
//เริ่มต้อน ฟังก์ชัน main()
int main (void){   
//ตัวอย่างการแสดงข้อความ

//แสดง .... ออกทางจอภาพ
printf(".............................\n");

//แสดง  Wel....
printf("Welcome to Benjamanusorn\n");  

//แสดง .... ออกทางจอภาพ
printf(".............................");  

//หยุดรอการกด คีร์บอร์ด ก่อนจะทำงานต่อไป
system("pause"); 

//ปิดฟังก์ชัน main()
} 



ตัวอย่าง การเขียนคอมเมนต์เพื่อบอกรายละเอียดของโปรแกรม

//FileName:comment_1.c
//Developer:krunoth@hotmail.com
#include  
int main (void){   

printf(".............................\n");
printf("Welcome to Benjamanusorn\n");  
printf(".............................");  
system("pause"); 

} 




2. /*หมายเหตุ*/ เขียนหมายเหตุไว้ระหว่าง /* และ */ ใช้ได้กับหมายเหตุที่มีขนาดความยาวตั้งแต่ 1 บรรทัดขึ้นไป

ตัวอย่าง การเขียนคอมเมนต์แบบมากกว่า 1 บรรทัด
/*
FileName:comment_2.c
Developer:krunoth@hotmail.com
*/
#include  
int main (void){   

printf(".............................\n");
printf("Welcome to Benjamanusorn\n");  
printf(".............................");  
system("pause"); 

} 




ตัวอย่าง การเขียนคอมเมนต์แบบมากกว่า 1 บรรทัด
/*
FileName:comment_2.c
Developer:krunoth@hotmail.com
*/
#include  
int main (void){   
/*
printf(".............................\n");
printf("Welcome to Benjamanusorn\n");  
printf(".............................");  
*/
printf("Chanthaburi\n");  
system("pause"); 

} 



Read more