ในภาษา C ไฟล์ส่วนหัวประกอบด้วยชุดของฟังก์ชันไลบรารีมาตรฐานที่กำหนดไว้ล่วงหน้า คำสั่งประมวลผลล่วงหน้า “#include” ใช้เพื่อรวมไฟล์ส่วนหัวที่มีนามสกุล “.h” ในโปรแกรม
นี่คือตารางที่แสดงไฟล์ส่วนหัวบางส่วนในภาษา C
| ซีเนียร์ | ไฟล์ส่วนหัวและคำอธิบาย |
|---|---|
| 1 | stdio.h ฟังก์ชันอินพุต/เอาต์พุต |
| 2 | conio.h คอนโซลอินพุต/เอาต์พุตฟังก์ชั่น |
| 3 | stdlib.h ฟังก์ชั่นยูทิลิตี้ทั่วไป |
| 4 | คณิตศาสตร์.h ฟังก์ชันคณิตศาสตร์ |
| 5 | string.h ฟังก์ชันสตริง |
| 6 | ctype.h ฟังก์ชั่นการจัดการตัวละคร |
| 7 | time.h ฟังก์ชันวันที่และเวลา |
| 8 | float.h ขีด จำกัด ของประเภทโฟลต |
| 9 | ขีดจำกัด.h ขนาดของประเภทพื้นฐาน |
| 10 | wctype.h ฟังก์ชันสำหรับกำหนดประเภทที่มีอยู่ในข้อมูลอักขระแบบกว้าง |
นี่คือตัวอย่างไฟล์ส่วนหัวในภาษา C
ตัวอย่าง
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main() {
char s1[20] = "53875";
char s2[10] = "Hello";
char s3[10] = "World";
int res;
res = pow(8, 4);
printf("Using math.h, The value is : %d\n", res);
long int a = atol(s1);
printf("Using stdlib.h, the string to long int : %d\n", a);
strcpy(s2, s3);
printf("Using string.h, the strings s2 and s3 : %s\t%s\n", s2, s3 );
return 0;
} ผลลัพธ์
นี่คือผลลัพธ์ -
Using math.h, The value is : 4096 Using stdlib.h, the string to long int : 53875 Using string.h, the strings s2 and s3 : World World