How to make your own data type like int, long in C?

1.2k Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

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.