Pregunta de entrevista de Voonik

How to reverse a string without using a temporary variable.

Respuesta de la entrevista

Anónimo

31 de jul de 2016

#include #include void main() { char s[100]; int i,j; clrscr(); printf("\nEnter the string : "); gets(s); i=0; j=strlen(s)-1; while(i < j) { s[i]=s[i]+s[j]; s[j]=s[i]-s[j]; s[i]=s[i]-s[j--]; i++; } // using built-in function: //n=strrev(s); printf("\nReverse string is : %s",s); getch(); }