+ 1
Why this simple code is showing error?
1 have used 2 strings and printed them but it is showing error. https://code.sololearn.com/cafUBwiRwRzv/?ref=app
1 Odpowiedź
+ 4
CHANGE:
char s[4] = "xyzm";
char t[4] = "abcd";
TO:
char s[5] = "xyzm";
char t[5] = "abcd";
When you do it that way (with the double quotes), it's automatically adding the null-terminated char at the end of it for you. As such, you'll want to increase the size of the array by 1 to accommodate that taking place or don't specify the size. Hope that helps!
HERE IS WHAT IT REALLY LOOKS LIKE:
char s[5] = {'x','y','z','m','\0'};