( asch | 2024. 03. 07., cs – 14:56 )

#include <stdio.h>
void printByPointer(const char * msg, int * arg) { printf("%s%d\n", msg, *arg); }
void incrementByPointer(int * arg) {
  /* Exact value depends on layout of actual compiler. see commented out printf below.
     The point is that it is possible to overwrite an other variable by error. */
  (*(arg+4))++;
}
int main(int argc, char **argv)
{
    int a = 112, b=112;
    (void) argc;
    (void) argv;
/*    printf("addressdiff: %d\n", (int)(&b-&a) );*/
    incrementByPointer(&a);
    printByPointer("a erteke: ", &a);
    printByPointer("b erteke: ", &b);
    return 0;
}
$ gcc -g -ansi -pedantic -Wall -Wextra -fsanitize=address trukkos2.c 
$ LD_PRELOAD=/usr/lib/gcc/x86_64-linux-gnu/9/libasan.so  ./a.out 
a erteke: 112
b erteke: 113