C++ Reverse Array

后端 未结 4 767
北恋
北恋 2020-12-01 20:22

In C++, I need to:

  • Read in a string from user input and place it into a char array [done]
  • Then pass that array to a function [done]
  • The funct
4条回答
  •  感动是毒
    2020-12-01 20:42

    Despite this looking quite homeworky, may I suggest:

    void reverse(char word[])
    {
        int len=strlen(word);
        char temp;
        for (int i=0;i

    or, better yet, the classic XOR implementation:

    void reverse(char word[])
    {
        int len=strlen(word);
        for (int i=0;i

提交回复
热议问题