Because what "char string[10]; " does is create an array of ten character wide memory locations (usually 1 byte).
You can't cram a string in that location.
Instead you need to create a 2D or string array as below:
Code:
#include <stdio.h>
int main (void) {
char string[5][10];
printf("enter some text\n");
scanf ("%s", string[3]);
printf("%s\n", string[3]);
printf("%s\n", string[4]);
return 0;
}
The problem with scanf as this program will show, is it doesn't know when to stop accepting characters from you entered string.
If you enter hhhhhkkkkklllll that is 15 characters, it will keep filling up into the next slot 'string[4]'.
Later you will learn fgets() which addresses that.