Question: i was trying to convert from a char array to integers and the atoi function is working properly except when i put a zero in the first index...it didn't print it

```
#include<iostream>

using namespace std;

int main()
{
    char arr[]= "0150234";
    int num;
    num=atoi(arr);
    cout << num;
    return 0;
}

```

I expect the output of 0150234 but the actual output is 150234

Answer: 
Binary number representations (such as `int`) do not store leading 0s because there is an infinite number of them. Rather they store a fixed number of bits which may have some leading 0 bits.

You can still print the leading 0s if necessary:

```
std::cout << std::setw(4) << std::setfill('0') << 1 << '\n';

```

Output:

```
0001

```
You're confusing two ideas:

**Numbers:** These are abstract things. They're quantities. Your computer stores the number in a manner that you should not care about (though it's probably binary).

**Representations:** These are ways we display numbers to humans, like *"150234"*, or *"0x24ADA"*, or *"one hundred and fifty thousand, two hundred and thirty four"*. You pick a representation when you convert to a string. When streaming to `std::cout` a representation is picked for you by default, but you can choose your own representation using I/O manipulators, as [Maxim shows](https://stackoverflow.com/a/55935150/560648).

The variable `num` is a *number*, not a representation of a number. It does not contain the information *«display this as "0150234"»*. That's what `arr` provides, because it is a string, containing a representation of a number. So, if that leading zero in the original representation is important to you, when you print `num`, you have to reproduce that representation yourself.

---

### By the way…

*Usually*, in the programming world, and particularly in C-like source code:

* When we see a string like *"150234"* we assume that it is the decimal (base-10) representation of a number;
* When we see a string like *"0x24ADA"* (with a leading `0x`) we assume that it is the hexadecimal (base-16) representation of a number;
* When we see a string like *"0150234"* (with a leading `0`) we assume that it is the octal (base-8) representation of a number.

So, if you do add a leading zero, you may confuse your users.

FYI the conventional base-8 representation of your number is *"0445332"*.