Home c Sing Pointers

Sing Pointers

Author

Date

Category

I try to figure out the signs. It seems to be understood as it began, but after these two simplest functions and their results, it was shot specifically.
Why is the swap () function working normally, and the SUM () function does not work at all? How to make so that Sum () earned. Thank you all in advance!

p.s. In the SUM () function, I tried to remove the asterisk at the summation operation – uncomfortable.

Code:

# include & lt; stdio.h & gt;
#Include & lt; stdlib.h & gt;
#Include & lt; String.h & gt;
Void Sum (int * c1, int * c2) {
  * C1 ++;
  * C2 ++;
}
Void SWAP (int * a, int * b) {
  int tmp = * a;
  * a = * b;
  * B = TMP;
}
INT MAIN () {
  int c1 = 1;
  INT C2 = 2;
  SUM (& amp; c1, & amp; c2);
  swap (& amp; c1, & amp; c2);
  PrintF ("C1 =% D, C2 =% D \ N", C1, C2);
  Return 0;
}

Result:

C1 = 2, C2 = 1

Answer 1, Authority 100%

(* c1) ++; (* C2) ++; – due to the priority of operators you need brackets.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions