I need to reverse a string and display the original using one function. I have the function to reverse it, but i dont know how to display the original one. Any help would be appreciated.
Code i have so far:
Code:#include <string.h> #include <stdio.h> #define CAPACITY 35 void reverseString(char *str) int main (void) { char first[CAPACITY]; char last[CAPACITY]; printf(" Enter your first and last name: "); scanf("%s %s", first, last); reverseString(first, first); reverseString(last, last); printf("The reverse of your name is: %s,%s \n", first, last); } void reverseString(char *str) { char *p = str; char *q = str + strlen(str) - 1; char temp; while(p<q) { temp = *p; *p = *q; *q = temp; ++p; --q; } }



LinkBack URL
About LinkBacks


