I am passing an array to a function whose size is determined by the user itself.
#include<stdio.h>
void mapper(int a[], int size);
int main ()
{
int n;
printf("Please provide the number of inputs\n");
scanf("%d",&n);
int array[n];
for(int i=0; i<n;i++)
{
scanf("%d",&array[i]);
}
mapper(array,n);
return 0;
}
void mapper (int a[], int size)
{
for (int i=0; i<size;i++)
{
for(int j=0; j<sizeof(a[i]);j++)
{
printf("#");
}
printf("\n");
}
}
When I run this program I get an error called the comparison of signed integer to unsigned integer. Why is it so? Is it because I have passed a[] as an argument and am later using a[i]?
How do you pass an array as an argument to a function whose size is to be determined?