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.


 Live Demo

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


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”.

Updated on: 26-Jun-2020


Kickstart Your Career

Get certified by completing the course

Get Started