I know that this is simple. I tried looking for an answer in stackoverflow before asking but couldn't find an answer.
char str[5], new_str[5];
int i, len;
printf("Enter a string: ");
scanf("%s", str);
len = strlen(str);
for (i = 0; i < len; i++){
new_str[i] = str[i];
}
printf("Result: %s", new_str);
I get:
Enter a string: 1234
Result: 1234╠╠╠╠╠╠╠╠╠╠╠1234
I know how to do it properly(using malloc) but I am trying to understand why this is output happened.