Question: Write a function called reverse that accepts a c-string as an argument and reverses that argument in place returning the address of the first element
Write a function called reverse that accepts a c-string as an argument and reverses that argument in place returning the address of the first element of the c-string as a character pointer when you are finished. For example, if your c-string contains the string Happy Birthday! then after a call to the function your string would contain !yadhtriB yppaH. For this assignment you may not use the string.h library or any other library except stdio.h. You may assume the following main program which would print the string forward, backward, and then forward again twice:
int main(int argc, char* argv[])
{
char word[] = "Happy Birthday!";
printf("%s ", word);
reverse(word);
printf("%s ", word);
printf("%s ", reverse(word));
printf("%s ", word);
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
