Function to reverse string in C

后端 未结 4 1218
终归单人心
终归单人心 2021-01-28 08:03

I wrote this function to reverse a string in C, but when switching characters in the string the program crashes. I have no idea what\'s causing it, so any help would be apprecia

4条回答
  •  情书的邮戳
    2021-01-28 08:33

    "Example" is a string literal, which usually means you cannot change it.

    Please try this:

    char str[] = "Example";
    reverse(str);
    

提交回复
热议问题