我不能相信我不能得到這個權利!有人請幫忙! 這是說沒有被初始化正在使用字(是必需的?):簡單的字符串處理sprintf
int main(int argc, char* argv[])
{
char* word;
sprintf(word,"%d",12);
std::cout << word;
return 0;
}
如果我是這樣做,它給調試斷言失敗!:
int main(int argc, char* argv[])
{
char* word = NULL; // char* word = nullptr;
sprintf(word,"%d",12);
std::cout << word;
return 0;
}
我已經包含了標準輸入輸出.h標題。我在這方面摸不着頭腦。
+1。應該添加'sprintf'被認爲是不安全的(http://stackoverflow.com/questions/3662899/understanding-the-dangers-of-sprintf) – Axel