相关疑难解决方法(0)

为什么这些构造使用前后增量未定义的行为?

#include <stdio.h>

int main(void)
{
   int i = 0;
   i = i++ + ++i;
   printf("%d\n", i); // 3

   i = 1;
   i = (i++);
   printf("%d\n", i); // 2 Should be 1, no ?

   volatile int u = 0;
   u = u++ + ++u;
   printf("%d\n", u); // 1

   u = 1;
   u = (u++);
   printf("%d\n", u); // 2 Should also be one, no ?

   register int v = 0;
   v = v++ + ++v;
   printf("%d\n", v); // 3 (Should be the …
Run Code Online (Sandbox Code Playgroud)

c increment operator-precedence undefined-behavior sequence-points

793
推荐指数
13
解决办法
7万
查看次数

麻烦在Visual Studio中调试c ++代码指针

我想列出列出的数组的每个成员及其相应的寄存器地址位置.这是我的代码

    // PointerDeferenceTest.cpp : Defines the entry point for the console application.
    //
    #include "stdafx.h"
    #include <iostream>
    using namespace std;
    int main()
    {
        int x=0, y=0;
        int *px, *py;

        int number[15] = {-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9};
        while (x<14)
        {
            px = &x;
            py = number+x;
            cout << x+1 << ", " << px << ", " << *px << ", " << py << ", " <<  *py << ", " << py++ << ", " << *(py++) << ", " << *(++py) …
Run Code Online (Sandbox Code Playgroud)

c++

0
推荐指数
1
解决办法
89
查看次数