20120113

Program in C to reverse a string using pointer

//========================
Program in C to reverse a string using pointer, revstrusingptr.c

#include<stdio.h>
#include<string.h>
int main()
{
char orgstr[50];
char revstr[50];
char *p1,*p2;
printf("Enter the string to reverse:\n");
scanf("%s",orgstr);
printf("You entered: %s \n", orgstr);
p1=orgstr+ strlen(orgstr)-1;
p2=revstr;
while(p1>=orgstr)
*p2++ = *p1--;
*p2='\0';
printf("Reversed String is: %s \n",revstr);
return 0;
}



Previous                             Home                               Next

4 comments:

  1. Program in C++/CPP/C to reverse a string using pointer
    Program in C++/CPP/C to reverse a string using pointer
    Program in C++/CPP/C to reverse a string using pointer
    Program in C++/CPP/C to reverse a string using pointer

    ReplyDelete
  2. Program in C++/CPP/C to reverse a string using pointer
    Program in C++/CPP/C to reverse a string using pointer
    Program in C++/CPP/C to reverse a string using pointer
    Program in C++/CPP/C to reverse a string using pointer

    ReplyDelete
  3. Program in C++/CPP/C to reverse a string using pointer
    Program in C++/CPP/C to reverse a string using pointer
    Program in C++/CPP/C to reverse a string using pointer
    Program in C++/CPP/C to reverse a string using pointer
    Program in C++/CPP/C to reverse a string using pointer
    Program in C++/CPP/C to reverse a string using pointer
    Program in C++/CPP/C to reverse a string using pointer
    Program in C++/CPP/C to reverse a string using pointer
    Program in C++/CPP/C to reverse a string using pointer
    Program in C++/CPP/C to reverse a string using pointer

    ReplyDelete
  4. C++ Program to reverse a string
    C++ Program to reverse a string
    C++ Program to reverse a string
    C++ Program to reverse a string
    C++ Program to reverse a string
    C++ Program to reverse a string
    C++ Program to reverse a string

    ReplyDelete