I couldn't believe that I couldn't get this right! Someone please help! This says word is being used without being initialised(Is that required?):
int main(int argc, char* argv[])
{
char* word;
sprintf(word,"%d",12);
std::cout << word;
return 0;
}
And if I were to do this, it gives DEBUG ASSERTION FAILED!:
int main(int argc, char* argv[])
{
char* word = NULL; // char* word = nullptr;
sprintf(word,"%d",12);
std::cout << word;
return 0;
}
I have included stdio.h header. It is not making sense how I am fumbling over this.