Ezat Elzalouy
Ezat Elzalouy

Reputation: 38

String to int in c++

How to convert a string variable that consists of maximum 100 char to big int ?

My code:

 long long int x;
 string s="11111111111111111111111111111111";
 x=atoll(s.c_str());
 cout<<x;

Upvotes: 1

Views: 84

Answers (1)

m0h4mm4d
m0h4mm4d

Reputation: 420

You need to use a bignum library, like GNU MP aka GMP or libcrypto.

Since in a 64-bit environment most compiler use 64 bits for a long long int, you can't even reach near 100 decimal digits with a long long.

Upvotes: 1

Related Questions