What you are trying to do does not work because the argument used in the printf
function is not correct. printf
is called like this:
printf ( const char * format, ... )
As you can see, it needs at least one argument which is a format string and it can take any number of additional arguments as indicated by the ellipsis (...
).
The format string may contain any number of format specifiers in the place of which the values of the additional arguments will be printed. Please note that the format specifiers and your additional arguments must match in both number and type.
What you did wrong is that you provided an illegal format string. If you want to print a character from your array your format string must be something that contains the format specifier for a character which is %c
. You must also provide the actual value as an additional argument. This means that for the 0-th character in your array the printf
should look something like this:
printf("%c", arr[0]);