I am quite a C programming newbie.
With answers for other question, I could understand the term "character" could point to vary elements; e.g. letters and numbers.
I am regarding "string" as characters.
Then, please take a look at the lines below:
#include <stdio.h>
main()
{
int numbers = 123;
printf("%c%s\n", "N", numbers);
}
When I tried to compile this code, error messages were displayed and compiling failed.
The textbook "The C Programming Language" page 13 says like below about printf format specifiers;
"
%cfor character""
%sfor character string".
First Question:
Although "N" is a character, why is %c specifier invalid?
Second Question:
Although the value of variable "numbers" is "123", they are numbers, which are included in the character.
I have thought characters equal "string."
Then, although I have used %s for "123", why is it invalid?
I know my code will work, if I revise them like one below:
#include <stdio.h>
main()
{
int numbers = 123;
printf("%s%d\n", "N", numbers);
}
but I would want to understand why the code above is invalid.