Is there a built-in way to swap two variables in C

后端 未结 10 1558
夕颜
夕颜 2020-12-01 14:53

I know how to swap 2 variables in c++ , ie you use std::swap(a,b).

question:

Does the C standard library have a similar function

10条回答
  •  借酒劲吻你
    2020-12-01 15:19

    There is no equivalent in C - in fact there can't be, as C doesn't have template functions. You will have to write separate functions for all the types you want to swap.

提交回复
热议问题