Reverse String without Built-In Functions

This program is to reverses a String without built-in functions . This is a part of Mumbai University MCA Colleges C Programs MCA Sem 1

This program uses the concept of Arrays for the same. And doesnt use built in string functions.
Can be made into C or C++ program

#include<iostream.h>
#include<conio.h>
char* rev(char *a,int n);
void main()
{
char *a;
char *b;
int n,m;
clrscr();
cout<<"Enter a string of chars ";
cin>>a;
cout<<"Enter the characters in the string";
cin>>m;
cout<<"The string is "<<a<<endl;
cout<<"Array size is "<<n;
b=rev(a,m);
cout<<"Revers of the array is "<<b;
getch();
}
char* rev(char a[],int n)
{
int i,j;
char *tmp;
for(i=0,j=n-1;i<n;i++,j--)
{
tmp[i]=a[j];
cout<<tmp[i]<<endl;;
}
tmp[i]=a[n];
return tmp;
}


Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

No comments:

Post a Comment