[Solved] Why basic C code throws Access violation


char arr[] = { 'a', 'b', 'c', 'd', 'e', 'f' };
printf("%c", arr[0]);

%s says print all the characters until you find a null (treat the variable as a pointer).

%c says print just one character (treat the variable as a character code)

Using %s for a character doesn’t work because the character is going to be treated like a pointer, then it’s going to try to print all the characters following that place in memory until it finds a null.

solved Why basic C code throws Access violation