Write a function called reverse that accepts a c-string as an argument and reverses that argument in place (meaning you should not create another array to store the result) 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 "lyadhtriB 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: #include char *reverse (char *word); int main(int arge, char* argv []) { char word [] "Happy Birthday!"; printf("%s\n", word); reverse (word); printf("%s\n", word); printf("%s\n", reverse (word)); printf("%s\n", word); return 0; } Place the code for your function in a file called reverse.c and submit only this file to me on blackboard. The file should contain the definition for your function reverse and nothing else. I will use my own header file and main program to test your code. Please keep in mind that this function should work for any valid C style string and the fact that the above program works for "Happy Birthday!" is just one example. You should try it with strings of even and odd lengths as well as very short strings.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
COMP.1020 Computing II
UMASS - Lowell
#include <stdio.h>
char *reverse(char *word);
Write a function called reverse that accepts a c-string as an argument and reverses that argument in place
(meaning you should not create another array to store the result) 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 "lyadhtriB 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 arge, char* argy [])
{
HW1 Spring 2023
char word [] "Happy Birthday!";
printf("%s\n", word);
reverse (word);
printf("%s\n", word);
printf("%s\n", reverse (word));
printf("%s\n", word);
return 0;
}
Place the code for your function in a file called reverse.c and submit only this file to me on blackboard. The
file should contain the definition for your function reverse and nothing else. I will use my own header file and
main program to test your code. Please keep in mind that this function should work for any valid C style
string and the fact that the above program works for "Happy Birthday!" is just one example. You should
try it with strings of even and odd lengths as well as very short strings.
Transcribed Image Text:COMP.1020 Computing II UMASS - Lowell #include <stdio.h> char *reverse(char *word); Write a function called reverse that accepts a c-string as an argument and reverses that argument in place (meaning you should not create another array to store the result) 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 "lyadhtriB 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 arge, char* argy []) { HW1 Spring 2023 char word [] "Happy Birthday!"; printf("%s\n", word); reverse (word); printf("%s\n", word); printf("%s\n", reverse (word)); printf("%s\n", word); return 0; } Place the code for your function in a file called reverse.c and submit only this file to me on blackboard. The file should contain the definition for your function reverse and nothing else. I will use my own header file and main program to test your code. Please keep in mind that this function should work for any valid C style string and the fact that the above program works for "Happy Birthday!" is just one example. You should try it with strings of even and odd lengths as well as very short strings.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education