Function to reverse string in C

后端 未结 4 1151
终归单人心
终归单人心 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:41

    You need to take character pointer as a parameter in your function:

    Void reverse (char *ptr)
    {
        // ...
    }
    

    And perform operation on pointer.

提交回复
热议问题