#include <stdio.h>
void fun(int *a, int *b) {
//printf("%d %d\n", a[2], *b);
++b; a[2] = a[1] + 6;
return;
}
int main(void) {
char A[5] = {'0', '1', '7', '3', '4'};
fun(A, A[2]);
printf("%c", A[2]);
}
I read here char to integer pointer conversion that accessing a char
array using int*
is undefined behaviour. Is this program similar to the one in that link?
Also, I want to know why I get a runtime error, if I uncomment the first statement in the funciton fun