this prints all ## these stuffs but also prints some junk value to end ? can anybody tell me why ?Code:#include <stdio.h> #include <string.h> void main (){ char str[50]; memset(str,'#',50); printf("%s",str); }
this prints all ## these stuffs but also prints some junk value to end ? can anybody tell me why ?Code:#include <stdio.h> #include <string.h> void main (){ char str[50]; memset(str,'#',50); printf("%s",str); }
I believe if you think about it you'll find that you haven't terminated the string; recall that in C a string is an array of characters terminated by the nul ('\0') character.
How many '#' characters can you fit in your array (char str[50]) remembering that you have to leave room for the final '\0' character?