Write a C program to reverse a string using pointers.
Program Code:
#include<stdio.h>
#include<string.h>
void main()
{
char *cp,s[30];
int i,length;
printf("\n enter a string: ");
gets(s);
cp=s;
length=strlen(s);
printf("\n the reverse of the string is : ");
for(i=length;i>=0;i--)
printf("%c",*(cp+i));
}
printf("\n\n Reversed string is:%s",rev);
getch();
}
Post A Comment:
0 comments: