How I (recursive) can reverse and print a string (as simple as
possible)? I tried with the following code, but it doesn't work. Thanks
in advance to everbody.
/* Code starts here */
#include <stdio.h>
void invstr(char* s) {
/* base case */
if ((*s) == '\0')
return;
else { /* general case */
invstr(s++);
printf("%c", *(s));
}
}
int main (int argc, char* argv[]) {
char* miastringa="CIAO";
invstr(miastringa);
system("PAUSE"); /* Because of Dev-C++ IDE */
return 0;
}
/* Code ends here */