#include "General.h" #include //--------------------------------------------------------------------------------------- // StringMirror // ------------ // // General : Recursive function that receives a string and returns a mirror string // of its inverted string. ("ABCD" = "DCBAABCD") // // Parameters : // str - a pointer of string (char *) // // Return value : mirror string of its inverted string. (char *). // //--------------------------------------------------------------------------------------- // Programmer : Cohen Idan // Student No : 211675038 // Date : 05.01.2019 //--------------------------------------------------------------------------------------- char * StringMirror(char * str) { string temp; unsigned int len; if (!(*(str + ONE))) { return (strcat(str, str)); } else { temp[ZERO] = *str; strcpy(temp + ONE, str); len = StringLength(str) - ONE; return (strcpy(StringMirror(str + ONE) + len, temp) - len); } } void main(void) { string s1 = " nehoC nadI"; printf("%s\n", StringMirror(s1)); }