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';
}
你在测试你的代码,多字符文字或未定义的行为?如果您只有一个关于多字符文字的问题,请删除导致未定义行为的其他代码,这与问题无关,并且不符合您的实际问题。 –