W
Who_Knows_Geek
#include <stdlib.h>
int main()
{
const char *strLeft = (const char*) malloc(10); // Left-operand
const char *strRight = (const char*) malloc(10); // Right-operand
strLeft = "123456789"; // Nine characters + the null-terminator.
strRight = "123456789"; // Nine characters + the null-terminator.
return 0;
}
This code is valid (no error) in VC++. WHY?
Isn't the memory refered by variables strLeft/strRight should've been
considered 'initialized' after the declaration?
'Just curious'
int main()
{
const char *strLeft = (const char*) malloc(10); // Left-operand
const char *strRight = (const char*) malloc(10); // Right-operand
strLeft = "123456789"; // Nine characters + the null-terminator.
strRight = "123456789"; // Nine characters + the null-terminator.
return 0;
}
This code is valid (no error) in VC++. WHY?
Isn't the memory refered by variables strLeft/strRight should've been
considered 'initialized' after the declaration?
'Just curious'