How to resolve “conflicting types error” in C?

后端 未结 7 618
情话喂你
情话喂你 2021-01-27 16:33

For the following C code (for swapping two numbers) I am getting the \"conflicting types\" error for swap function:

#include 
#includ         


        
7条回答
  •  执笔经年
    2021-01-27 17:11

    First off, the actual error message wouldn't hurt.

    Secondly, making buffer of [size] only works on some compilers (that's a new feature, not all compilers have it yet). Are you sure yours does?

    Thirdly, you need to declare swap before calling it. Add a prototype at the top of the file:

    void swap(void *p1,void *p2,int size);
    

提交回复
热议问题