Having difficulty printing strings

后端 未结 5 522
走了就别回头了
走了就别回头了 2021-01-22 06:35

When I run the program, the second printf() prints string2 with whatever was scanned into string1 attached to the end.

e.g.

5条回答
  •  旧时难觅i
    2021-01-22 07:11

    Expanding on the previous answers, the strings appear to be joined due to the order the variables are stored in the stack memory. This won't always work the same on every processor architecture or compiler (optimiser settings can change this behaviour too).

提交回复
热议问题