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

Data Types ที่ไม่สามารถสร้าง array ได้ใน C


Array สร้างได้จาก data types ทั้งหมด: int, char, float, double ฯลฯ แต่สร้าง array ด้วย void data type ไม่ได้ จะแสดง error

โปรแกรมสาธิต:

ตัวอย่าง

#include <stdio.h> #include <stdlib.h> int main() {    void arr1[4];    printf("A void array");    return 0; }

Output

The above program returns the following error.

error: declaration of ‘arr1’ as array of voids void arr1[4];

เข้าใจโปรแกรมข้างต้น:

Array arr1 ของ void data type ถูกสร้าง เนื่องจากทำไม่ได้ใน C error message แสดง “declaration of ‘arr1’ as array of voids”