| functions/functions-output-2-a-wrong.c - Der udføres pointer aritmetik på pointerne - usikkert og uden god mening. | Lektion 6 - slide 8 : 21 Program 13 |
#include <stdio.h>
/* Output: We attempt to pass two pointers to g - but the pointers are not good...
Compiles. May or may not run. */
void g(int *fp1, int *fp2){
*fp1 = *fp1 + 1;
*fp2 = 6;
printf("*fp1 + *fp2 = %d + %d = %d\n", *fp1, *fp2, *fp1 + *fp2);
}
int main(void) {
int i = 3,
j = 4;
g(&i + 1, &j + 2); /* Now Lvalues, but unsafe! */
printf("i + j = %d + %d = %d\n", i, j, i + j);
return 0;
}