This equation swaps two numbers without a temporary variable, but uses arithmetic operations:
a = (a+b) - (b=a);
How can I do it without ar
I haven't seen this C solution before, but I'm sure someone has thought of it. And perhaps had more posting self-control than I do.
fprintf(fopen("temp.txt", "w"), "%d", a);
a = b;
fscanf(fopen("temp.txt", "r"), "%d", &b);
No extra variables!
It works for me, but depending on the stdio implementation you may have to do something about output buffering.