I am creating a program that takes a numerical input from the user as a long long, and then there is some maths involved with individual digits. I think the best way to do this is to convert the long long to a string and then iterate over the various parts.
I have tried using atoi
but that did not work, and now i am playing with sprintf
as follows...
if (count == 13 || count == 15 || count == 16)
{
char str_number[count];
// Converting long card_number to a string (array of chars)
sprintf(str_number, "%lld", card_number);
printf("card number is: %s\n");
return 0;
}
This does not work either.
Can anyone set me on the right track please?