Initialization makes pointer from integer without a cast - C

前端 未结 4 2334
执笔经年
执笔经年 2021-02-08 09:10

Sorry if this post comes off as ignorant, but I\'m still very new to C, so I don\'t have a great understanding of it. Right now I\'m trying to figure out pointers.

I mad

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-08 09:30

    Maybe too late, but as a complement to the rest of the answers, just my 2 cents:

    void change(int *b, int c)
    {
         *b = c;
    }
    
    int main()
    {
        int a = 25;
        change(&a, 20); --> with an added parameter
        printf("%d", a);
        return 0;
    }
    

    In pointer declarations, you should only assign the address of other variables e.g "&a"..

提交回复
热议问题