English 中文(简体)
0+=VARIABLE如何导致VARIABLE+1?
原标题:How does 0+= VARIABLE result in VARIABLE+1?

在更新用于计算开关表变量的柜台时,我陷入了奇怪的 b。

int iCount was assigned zero outside of the loop, and it is the counter used for the while loop.

为了更新通道内的反响,我写道:i。 包装的海标+ = 包装的 本案为7。 然而,在浮标中,0+=包装 结果是包装了Count+1, 即8。 这导致整个坡道仍有一个阵列尚未填满。

当我把该线路改为icount=包装Count+iCount时,则将适当数值退还。

因此,这种行为是C所独有的,因为我经常在 Java这样做,没有奇怪的影响。

http://www.ohchr.org。 补充法律

#define SKIP   8
#define PACKED 7

int iCount;
iCount=0;

while (iCount < characters-1){  
    for (packedCount=iCount; packedCount< iCount+PACKED; packedCount++){ 
        //ASCII compressor logic goes here
    }
    //iCount+= packedCount; //this produces 8 for 0+packedCount

    //this works
    iCount= iCount+packedCount; //skip the next byte in array, since it was already packed
}
问题回答

As far as the compilers are concerned

iCount += packedCount;
iCount = iCount + packedCount;

相同。 如果它们重新产生不同的结果,那么你法典中的一些内容就会使iCount被拖走——也许是一个不好的参照。

ry , , ,

#define SKIP   8
#define PACKED 7

int iCount;
iCount=0;

while (iCount < characters-1){  
    for (packedCount=iCount; packedCount< iCount+PACKED; packedCount++){ 
        //ASCII compressor logic goes here
    }
    printf("iCount after the inner loop: %d
", iCount);             /* DEBUG */
    printf("packedCount after the inner loop: %d
", packedCount);   /* DEBUG */

    //iCount+= packedCount; //this produces 8 for 0+packedCount

    //this works
    iCount= iCount+packedCount; //skip the next byte in array, since it was already packed

    printf("iCount after update: %d
", iCount);                     /* DEBUG */
}




相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...