How do you reverse a string in place in C or C++?

前端 未结 30 1897
长发绾君心
长发绾君心 2020-11-22 00:37

How do you reverse a string in C or C++ without requiring a separate buffer to hold the reversed string?

30条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-22 01:40

    Here's my take on it in C. Did it for practice and tried to be as concise as possible! You enter a string via the command line, i.e ./program_name "enter string here"

    #include 
    #include 
    
    void reverse(int s,int e,int len,char t,char* arg) {
       for(;s

提交回复
热议问题