I have begun learning C on my own. I am using Head First C.
The below program is a bit confusing to me:
#include <stdio.h>
int main()
{
puts("Hello World!");
puts("Enter your favorite Number:");
char arrayOfNumbers[3];
scanf("%2s",arrayOfNumbers);
//printf(arrayOfNumbers);
char s[] = {'a','b','c','d','e'};
printf(s);
return 0;
}
The output of this program is :
Hello World!
Enter your favorite Number:
1
abcde1
What I don't get is, inspite of the fact that I am copying the input '1' in the array arrayOfNumbers, and then I am printing the array 's', the output contains the 1 I entered. How is the input being copied to the array 's'?