How to Print Big Number?

I don't need anything or any calculation. I just need to take a big number as input and print it. I think it's not so hard but I can't print it. Can anyone help me?
For example: I just take 9999999999999999999999 as input, so my task is to print 9999999999999999999999. Can anyone tell me how can I do it?

N.B: I want to do it in C/C++.
- Thanks
Last edited on
You can use a string or, if the number will fit, you can try unsigned long long. A string will hold a vary large number, however, you won't be able to do math or anything with it without parsing it.
I know that I need to use string because the max value will cross 2^63, but the problem is, my code can't print the actual number. It's just print some character. How can I solve it?
If your program reads a string as input, then it should be able to output that string too.
It's impossible to say what's wrong with your code without seeing the actual code.
try :

_int64 in visual c++ for the biggest variable type....... i think it worked for me
I don't believe a 64 bit int can hold 24 digits. An unsigned 64 int can hold a max value of 18,446,744,073,709,551,615. A string or a custom sized variable is about the only way to go.

As Chervil said, if you store the inputted number as a string, displaying the string is just as easy:
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <string>

int main() {
   std::string reallyBigNumber;

   std::cout << "Please enter your number: ";
   std::cin >> reallyBigNumber; // 999999999999999999999999

   std::cout << "You entered: " << reallyBigNumber; // You entered: 999999999999999999999999

   return 0;
}
Topic archived. No new replies allowed.