How to store a number of 10 or more digits. | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 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......

9th Aug 2019, 5:41 PM
Rodian Josué Matey Martínez
Rodian Josué Matey Martínez - avatar
4 Réponses
+ 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...";
9th Aug 2019, 5:43 PM
Airree
Airree - avatar
+ 5
use double or long double 32 bit machines can do it using long int too 😉
10th Aug 2019, 1:18 AM
Aditya
Aditya - avatar
+ 2
Use long int.
11th Aug 2019, 10:50 AM
Manoj
Manoj - avatar
+ 2
I have done it, I used Long Long. Thanks everyone
2nd Sep 2019, 4:40 PM
Rodian Josué Matey Martínez
Rodian Josué Matey Martínez - avatar