# Visual C++ & C++ Programming > Visual C++ Programming >  adding  + 1 with strlen?

## FoxieWike

What does the following code do?
why the code is adding  + 1 with strlen?



```
v4 = (char *)malloc(0x400u);

strlen(v4) + 1;
```

----------


## salem_c

The +1 is necessary to count the \0 at the end of the string.

"abc" has a strlen result of 3, but it is stored in memory as "abc\0".

So if you wanted to allocate space to store "abc", you would need 4 bytes to do it.

----------


## 2kaud

Note that malloc() returns a pointer to_ uninitialised_ storage. If the memory pointed to by v4 after malloc() is not initialised before use, it is unknown to what v4 points. Unless v4 memory is initialised between the malloc() and strlen() statements, the result of strlen() is unknown.

----------

