1. How come that changing the size of the memory allocated new char(256);
the size of the file wont change?
2. Why do we need to clear it with memset, when i write "world" to it and print it
hello is no longer there. Looks like it clears itself.
Code:
#include <iostream>
#include <windows.h>
using namespace std;
char *buffer = new char(256);
int main()
{
strcpy(buffer, "hello");
cout << buffer << "\n";
strcpy(buffer, "world");
cout << buffer << "\n";
memset(buffer, 0, 256);
cout << buffer << "\n";
delete buffer;
return 0;
}