Question
C program (not C++) Write a function in C called reverse string that takes in any size string and returns the reverse of the string.
C program (not C++)
Write a function in C called reverse string that takes in any size string and returns the reverse of the string. the code must Use pop and push functions as described below. (the program must take user input)
-declare a stack variable ex: char stack[s]
-declare a string variable called reversed within the function. this should be returned by the function and printed.
-if a string is entered, push all the individual characters into the stack. the last character in the string is pushed last
- pop all the characters from the stack to the reversed string function, until the stack is empty. the last character pushed is popped first.
- return and print the reverse string.
EX.
input: cat and dog
output: god dna tac
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started