title: Swap specific text in string
body: <p>I need to write a function <em>swapLetters</em> that receives two strings. The function transforms the string received as the first parameter by replacing the first character from the string that is passed as the second parameter with the last character from the same string, the second with the previous one, etc. to the middle of the string. If the second parameter contains an odd number of characters, nothing needs to be done with the character in the middle. If one of the parameters is an empty string, the function does not need to do anything.</p>
  <p>For example:</p>
  <pre><code>char text[9]=&quot;dobar dan&quot;, letters[5]=&quot;abcde&quot;;
  </code></pre>
  <p>OUTPUT:</p>
  <pre><code>After transformation text is: 'doder den'
  </code></pre>
  <p>Explanation: first character in the string <em>letters</em> is &quot;a&quot;, and in the string <em>text</em>, character &quot;a&quot; is replaced by the last character of string <em>letters</em>, which is &quot;e&quot;. The second charater from string <em>letters</em> is &quot;b&quot;, and in the string <em>text</em>, charater &quot;b&quot; is replaced by the penultimate character of string <em>letters</em>, which is &quot;d&quot;, while with the letter &quot;c &quot;nothing has been done because it is in the middle of the string <em>letters</em> and there the function stops.</p>
  <p>The function should return the cursor to the beginning of a text string for easier chain calling.</p>
  <p>*Note: Auxiliary strings are not allowed</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  char *swapLetters(char *s1, char *s2) {
    int lenght1 = 0, lenght2 = 0;
    char *q1 = s1, *q2 = s2;
    while (*q1 != '\0') {
      lenght1++;
      q1++;
    }
    while (*q2 != '\0') {
      lenght2++;
      q2++;
    }
    return s1;
  }
  
  int main() {
    char text[9] = &quot;dobar dan&quot;, letters[5] = &quot;abcde&quot;;
    swapLetters(text, letters);
    printf(&quot;After transformation text is: '%s'\n&quot;, text);
    return 0;
  }
  </code></pre>
  <p>Could you help me with this task? Strings are new to me.</p>