Reverse the given string(including space) With and Without strrev() function - easy

#include <stdio.h>
#include <string.h>
#include <conio.h>

int main(void)
{
    //reverse string (without function):

    char a[100];
    char b[100];
    int l = 0;

    printf("Enter the string to reverse : ");
    gets(a);
    for (int i = 0a[i] != '\0'; i++)
    {
        l++;
    }

    int count = l - 1;
    for (int i = 0; i <= l - 1; i++)
    {
        b[count] = a[i];
        count--;
    }
    printf("%s\n", b);

    // using the inbuilt function to reverse string

    strrev(a);
    printf("%s", a);
}
SHARE

Milan Tomic

Hi. I’m Designer of Blog Magic. I’m CEO/Founder of ThemeXpose. I’m Creative Art Director, Web Designer, UI/UX Designer, Interaction Designer, Industrial Designer, Web Developer, Business Enthusiast, StartUp Enthusiast, Speaker, Writer and Photographer. Inspired to make things looks better.

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment