Why exactly is the char array I created and initialized with a value not being printed correctly and instead some random characters/garbage value being printed out?
Here is my code:
class CharArrayChecker
{
public:
CharArrayChecker() {};
char* GetCharArray();
};
char* CharArrayChecker::GetCharArray()
{
char Output[32] = "This is a test";
return Output;
}
int main()
{
CharArrayChecker* CharArrayCheck = new CharArrayChecker();
const char* Test = CharArrayCheck->GetCharArray();
printf("Output: %s\n\n", Test);
return 0;
}