+ 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

8th Jun 2018, 6:58 PM
Karandeep Singh Ajmani
Karandeep Singh Ajmani - avatar
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'};
8th Jun 2018, 7:29 PM
Fata1 Err0r
Fata1 Err0r - avatar