1
我正在檢查一些我在stackoverflow上看到的答案,並以一種不應該根據非常有經驗的程序員工作的方式改變行,令人驚訝的是它做到了。任何人都可以解釋爲什麼可能嗎? 問題是一個字符常量與一個以上的字符(我使用Visual Studio 2013)字符常量與更多的一個字符
// stack.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using std::cout;
int * foo()
{
int a = 5;
return &a;
}
int main()
{
int* p = foo();
cout << *p << ' '; // this line should not compile but it did???
*p = 8;
cout << *p << '\n';
}
你在測試你的代碼,多字符文字或未定義的行爲?如果您只有一個關於多字符文字的問題,請刪除導致未定義行爲的其他代碼,這與問題無關,並且不符合您的實際問題。 –