为什么参数值不会随着该变量的传递地址而增加?

use*_*119 2 c pointers

嗨,我有以下程序

#include <stdio.h>
#include <string.h>

void fun1(int *getValue)
{
    for(int i=0;i<4;i++)
        *getValue++;
}

void fun2(int *getValue)
{
    for(int i=0;i<4;i++)
        *getValue=+1;
}

void main()
{
    int getValue=0,getValu2=0;
    fun1(&getValue);    
    fun2(&getValu2);
    printf("getValue :%d and getValu2 : %d\n", getValue, getValu2);
}
Run Code Online (Sandbox Code Playgroud)

以上程序的o/p是

getValue :0 and getValu2 : 1
Run Code Online (Sandbox Code Playgroud)

现在我期待两种情况下的价值应该是4因为我在函数中传递了变量的地址?我的理解是错的,这种行为是否正确?如果是,那么任何人都能解释一下吗?我需要什么修改来获得正确的价值?

Dav*_*eri 5

在第一种情况下,您增加指针的地址(而不是传递的变量的值):

改成:

(*getValue)++;
Run Code Online (Sandbox Code Playgroud)

在第二种情况下,您总是分配 +1

改成

*getValue+=1;
Run Code Online (Sandbox Code Playgroud)

现在它应该是4和4