Reputation: 9
I'm beginner in c
and I want to create my own data type which I can use like int
but to store bigger numbers. For example, how can I allocate memory for this data type with malloc?
Upvotes: 0
Views: 1290
Reputation: 1
Read some C programming book about struct
-ures, union
-s, pointers, and data types. Read more about C dynamic memory allocation
To deal with big numbers, you'll better use some bignum (a.k.a. arbitrary-precision arithmetic) library, such as GMPlib. So your question becomes implementation and operating system specific.
Notice that bignum arithmetic involves tricky and difficult algorithms (better than naive approaches).
You should become more fluent about programming in C before using it (GMPlib). Be afraid of undefined behavior and memory leaks.
Upvotes: 4