i have used the code.
char *y;
y="hello world";
printf("%c",y);
it just shows something useless. What mistake i am making.
i have used the code.
char *y;
y="hello world";
printf("%c",y);
it just shows something useless. What mistake i am making.
Change :
printf("%c",y);
to :
printf("%s",y);
as %c specifier indicates a char. To identify a string, you need the specifier %s.
It is undefined behaviour because you have used wrong format specifier.
C11 Standard: §7.21.6.1: Paragraph 9:
If a conversion specification is invalid, the behavior is undefined.225) If any argument is not the correct type for the corresponding coversion specification, the behavior is undefined.
So, use %s instead of %c for character string.