I know how to swap two variables in C++, ie you use std::swap(a,b).
Does the C standard library have a similar function to C++’s std::swap(), or do I have to define it myself?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.