Integer not storing more than 0ne zeros in C++

I want to store more than one zeros in Integer

1
2
3
4
5
6
7
8
9
  #include <iostream>
using namespace std;
int main()
{
int number = 00000000;   //number not storing more than one zeros
cout <<number;
return 0;
}
Your question makes no sense. 0 has the same value as 00000000. They're the same number, so storing:

int number = 00000000;

does exactly the same thing as:

int number = 0;

I think what you really mean is that you want to display the value differently. To control how your numbers are displayed in the cout statement, you can use i/o manipulators - see, for reference:

http://www.cplusplus.com/reference/ios/

Alternatively, if you're only interested in displaying number, and not performing jumerical operations on it, you could simply define it as a string, instead.
Hi
you have to use the bitset not int

1
2
3
4
5
6
7
#include <iostream>
#include <bitset>

int main(){
    std::bitset<8> x(00000000);
    std::cout<<x;
}
Topic archived. No new replies allowed.