how to reverse texts using/without using functions

The second part(where I don't make use of a function) works, the first part...

#include <iostream>
#include<stdio.h>
using namespace std;

void reverse(int x,int y,char z){
for(int ctr=0;ctr<x;ctr++){
cout<<z[y];
y--;
}
}

int main(){
//using function
int aa;
cout<<"Reversing Texts Using Functions..."<<endl;
system("pause");
cout<<"Number of characters to reverse: ";
cin>>aa;
int bb=aa-1;
char cc[bb];
cout<<"Text to be reversed: ";
cin>>cc;
reverse(aa,bb,cc);
system("pause");
//using function
system("cls");
cout<<"Reversing Texts Without Functions..."<<endl;
system("pause");
//without function
int a;
cout<<"Number of characters to reverse: ";
cin>>a;
int b=a-1;
char c[b];
cout<<"Text to be reversed: ";
cin>>c;
for(int ctr=0;ctr<a;ctr++){
cout<<c[b];
b--;
}
//without function
}
First, void reverse(int x,int y,char z) should be changed to void reverse(int x,int y,char z[]).
Topic archived. No new replies allowed.