+ 2
How to store a number of 10 or more digits.
From>MR to>you I've been working in a project which consists of knowing if a credit card is true. But as we know a credit card can have from 13 to 16 digits or number. But in C , I cannot store a number with this amount of digits. I know that we have the variable int long, but long just take 10 digits. So, I want to know, how to store or save a number with this characteristics. Thanks......
6 Antworten
+ 7
Arrays. Arrays, arrays, arrays.
Arrays can hold as many values of the same type, and you probably should store them as characters:
char creditCardNumber[16] = {'1', '2', '3', '4', '5', '6' /* ... */};
Or, use strings:
char creditCardNumber[16] = "123456...";
+ 5
use double
or long double
32 bit machines can do it using long int too 😉
+ 2
Use long int.
+ 2
I have done it, I used Long Long. Thanks everyone