So basically I have to write a program which works with integers ranging from 0 to 10^18 digits long. I was trying to see how can I input such long number in C and then use it. I decided to use unsigned long long int but after using that the program in not accepting input in the String a,and exits.I am unable to understand what is happening inside the code.
#include <stdio.h>
#include <string.h>
int main()
{
int i,length=0;
unsigned long long p;
scanf("%llu",&p);
printf("%llu\n",p);
char a[19];
scanf("%[^\n]s",a);
length=strlen(a);
printf("%d\n",length);
int b[length];
for(i=0;i<length;i++)
{
b[i]=a[i]-48;
}
printf("Input is : ");
for(i=0;i<length;i++)
{
printf("%d",b[i]);
}
//printf("%d\n",b);
return 0;
}
The input I gave was 34 then the next lines were:
34
2
Input is : 4816