Hey all, used this forum a couple weeks ago and it was great...have a couple of questions about arrays right now...
I have this code:
the array astring suppose to get only 10 elements right?!Code:#include <stdio.h> #include<stdlib.h> int main() { char astring[10]; scanf( "%s", astring ); printf("%s", astring); return 0; }
but if I put aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ( which is more than 10 elements), it will print it out all of the As!!! why is it like that?!
and why if I press "space" in between my characters when I'm inputting them, it won't print out the characters after space?!
what can I do to assign an empty element(like space) in one of my slots in the array?!
(I mean I wanted it to print a FIRSTNAME LASTNAME thing, like John Terry, with space in between, but it will only print out John...)