In a test document I found I got asked what the problem in following code is:
#include <iostream>
#include <stdlib.h>
#include <string.h>
using namespace std;
int main()
{
char* a = (char*) malloc (20);
char* b = (char*) malloc (20);
strcpy(b, "Secure Coding");
strcpy(a, "Insecure Coding");
a = b;
cout << a << endl;
cout << b << endl << endl;
free(a);
free(b);
return 0;
}
What is it?