i am new to c++ and trying to learn the language from the ground up. today i was learning about pointers and if i understand the code below correctly,
i am allocating 8 bytes of memory with a pointer named 'buffer' and using memset function, i am putting 0 into each byte and i want the whole memory to be filled with 0 so the full length of this is 8 so, i set it to be 0.
which if i run in debug mode, should return at this memory address of buffer
00 00 00 00 00 00 00 00
but instead, i get
cd cd cd cd cd cd cd cd
#include <iostream>
int main()
{
char* buffer = new char[8];
memset(buffer, 0, 8);
delete[] buffer;
std::cin.get();
}
Again, I come from javascript/python background and memory, heap, stack are all new to me. please help me fix this...