Search This Blog

Wednesday, 2 March 2022

B8. Write a C Program to Reverse a String using Pointer.

 //B8. Write a C Program to Reverse a String using Pointer.
#include<stdio.h>
#include<conio.h>
void main()
{
    char *s;
    int len,i;
    clrscr();

    printf("\nEnter a String:\n");
    gets(s);

    len=strlen(s);
    printf("\nThe reverse of String is:\n");

    for(i=len;i>=0;i--)
        printf("%c",*(s+i));
    getch();
}

No comments :

Post a Comment

FREE Hit Counters