Im learning C right now and I've got this problem I want to convert the integer into an array my code works but the problem is that I declare the size of an array in the beginning and I want to make it so that it works for every integer basically.
#include<stdio.h>
int main()
{
int x,i,temp;
int arr1[6];
scanf("%d",&x);
for (i=5;i>=0;i--){
temp=x%10;
arr1[i]=temp;
x/=10;
}
for (i=0;i<=5;i++){
printf("%d",arr1[i]);
}
return 0;
}
Can you please help me?
I'm trying to find solution for the problem.