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();
}
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: