reverses the contents of string str. You are required to #include the header file <string.h>. - C String

C examples for String:String Function

Description

reverses the contents of string str. You are required to #include the header file <string.h>.

void reverse(char str[])
{
  int ch, j, k;
  for(j = 0, k = strlen(str) - 1; j < k; j++, k--)
    ch = str[j], str[j] = str[k], str[k] = ch;
}

Related Tutorials