Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/159.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ std::cout是否具有容纳字符的最大大小? #包括 int main(){ int b=3; int*a; *a=b; 标准::cout_C++ - Fatal编程技术网

C++ std::cout是否具有容纳字符的最大大小? #包括 int main(){ int b=3; int*a; *a=b; 标准::cout

C++ std::cout是否具有容纳字符的最大大小? #包括 int main(){ int b=3; int*a; *a=b; 标准::cout,c++,C++,为什么我看到分割错误 因为程序的行为未定义。以下是程序中的错误列表: std::您是否已经在*a=b中有UB。因为指针a未初始化,并且指向任何地方(或任何地方)。这是U.B.。只要您通过*a访问内容/引用,您就可以执行a=&B;。然后a将指向B的存储并进行定义。 *a = b; ^^ indirect through indeterminate pointer std::cout << &a << a << *a;

为什么我看到分割错误

因为程序的行为未定义。以下是程序中的错误列表:


std::您是否已经在
*a=b
中有UB。因为指针
a
未初始化,并且指向任何地方(或任何地方)。这是U.B.。只要您通过
*a
访问内容/引用,您就可以执行
a=&B;
。然后
a
将指向
B
的存储并进行定义。
*a = b;
^^
indirect through indeterminate pointer
std::cout << &a << a << *a;
                   ^    ^^
                   |    indirect through indeterminate pointer
                   read an indeterminate value