Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<stack>
- using namespace std;
- void reverseString(char* c, int n);
- int main(){
- char c[50];
- cout << "Enter a string: ";
- gets(c);
- reverseString(c, strlen(c));
- printf("%s\n", c);
- return 0;
- }
- void reverseString(char* c, int n){
- stack<char> s;
- for(int i=0; i<n; i++){
- s.push(c[i]);
- }
- for(int i=0; i<n; i++){
- c[i] = s.top();
- s.pop();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement