First post on this website, I'm a newbie to C Programming. I've got my head around data types.
I want to be able to ask the user to input a string of text and store it in an array. I have created the following test program to see if my code is able to display the 3rd char element of what the user had input.
What this program does instead is crash on me, any idea why?Code:#include <stdio.h> int main() { char string[10]; printf("enter some text"); scanf ("%s", string); printf("%s", string[3]); return 0; }
Also since I've declared the number 10 in the string, does this mean that my program will indeed accept only 9 char values? (*-1)



3Likes
LinkBack URL
About LinkBacks




