Computer >> Computer tutorials >  >> Programming >> C programming

Data Types we cannot use to create array in C


An array can be created using all data types such as int, char, float, double etc. But creating an array by using the void data type is not possible. An error will be displayed if that is done.

A program that demonstrates this is given as follows.

Example

#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];

Now let us understand the above program.

An array arr1 of void data type is created in the above program. Since this is not possible in C, an error message is displayed i.e. “declaration of ‘arr1’ as array of voids”.