The following code prints (compiled with clang)
Output
[A][?][?]
Code
#include <stdio.h>
int main(){
char a = "A";
printf("[A]");
printf("[%c]", a);
printf("[%c]", "A");
}
Gives a warning (clang does)
test.c:4:10: warning: incompatible pointer to integer conversion initializing
'char' with an expression of type 'char [2]' [-Wint-conversion]
char a = "A";
^ ~~~
test.c:7:20: warning: format specifies type 'int' but the argument has type
'char *' [-Wformat]
printf("[%c]", "A");
~~ ^~~
%s
However
Output
[A][z][z]Characters: a A
Code
int main(){
char a = "A";
printf("[A]");
printf("[%c]", a);
printf("[%c]", "A");
printf ("Characters: %c %c \n", 'a', 65);
}
I'm thinking it has something to do with the memory and integers (both because of the warning and because the "A" that is rendered as a "?" goes to a "z", that is "A"--).