My Project - Video Waker Alarm
Get Video alarm on Google Play

Reverse string c code without using string function


Reverse string c code without using string function. This c program to reverse string without using string function, will accept an input string and display it in reverse using arrays. Reversing of string can also done by using pointers and with the help of functions. You can see other string operation in c and other c program to implement string operations.

Reverse string c code without using string function

          #include<stdio.h>
          #include<conio.h>
          #include<string.h>
        
          int main()
          {
              int j,l,i;
               char s[10];
               printf("\n\nEnter the String to get reversed\n");
               gets(s);// taking string in variable s
              
                    l=strlen(s);
                    printf("\n\nreverse string is \n");
                    for(j=l-1;j>=0;j--)
                    {
                                       printf("%c",s[j]);
                    }
               getch();
           }

output of Reverse string c code:

Reverse string c code
output: Reverse string c code

Qoute of the post : “That’s what’s cool about working with computers.  They don’t argue, they remember everything, and they don’t drink all your beer.” – Paul Leary


3 thoughts on “Reverse string c code without using string function”

  1. #include
    #include
    char *reverse(char *p,int len)
    {
    static char rev[12];
    int i=0,j=0;
    for(i=0,j=len-1;i<len;i++,j–)
    {
    rev[i]=p[j];
    }
    rev[i++]='';

    printf("reversed string is=%s\n",rev);
    return rev;
    }
    int main()
    {
    int len=0;
    char string[]="stinga",*p=NULL;
    len=strlen(string);
    p=reverse(string,len);
    printf("reversed string=%s\n",p);
    }

  2. This c program to reverse a string works perfectly fine. All the programs listed on this blog are perfect and excellent . Thanks a lot for sharing.

Leave a Reply

Your email address will not be published. Required fields are marked *