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
Get step-by-step solutions from verified subject matter experts
