Blogger Tips And Tricks|Latest Tips For Bloggers Free Backlinks

Saturday, 17 November 2012

Write a program to find the Reverse of the given string strrev() using pointers in C language examples?

Reverse of the string,string reverse,C string reverse,find string reverse,reverse of the string using pointers,find reverse of the string in C, Write a program to reverse of the given string using pointers in C language,string reverse program,find string reverse using pointers in C,find strrev()


 String Reverse

      The program is for reverse the given string in destination

                            #include<stdio.h>
                            void stringReverse(char *);

                            main()
                            {
                                  char source[100];

                                    printf("Enter String\n");
                                    scanf("%[^\n]",source);

                                       stringReverse(source);

                                      printf("After Reverse the string is : %s\n",source);
                             }
                             
                               void stringReverse(char *str)

                              {
                                            int len = 0,i=0;
                                            len = strlen(str);
                                             char *t = str + len - 1;
                 
                                          while(i < len/2)

                                               {
                                                     char temp = *str;
                                                     *str = *t;
                                                      *t = temp;
                                                     *str++;
                                                      *t-- ;
                                                      i++;
                                               }
                               }

                 Output:
                               Enter String
                                 Hello World
                                After Reverse the string :dlroW olleH

0 comments:

Post a Comment