Q:

C Program For Reverse a String Using Pointers

0

Reverse a string using pointers c++ or C Program For Reverse A String Using Pointer or reverse a string using pointers c++ using while loop or c program to reverse a string using pointers with explanation or Reverse a string using pointers or Reverse a string using pointers in C or How to Reverse String using Pointer in C or C Program to Reverse String Without Using Library Function or String Reverse Using pointers or Reverse all words and string using pointer or c program to reverse a string using pointer and loop or Reverse the String Using FOR Loop and Pointers in C or Write a C program to reverse a string using pointers or C program to reverse a string using pointers.

 

Explanation:- 

Reverse a string using pointers is very likely as Stack program it also follow the same rule of Stack FILO (First In Last Out) in Reverse a string using pointers we are doing same when we are taking input from user at same time we are calculating the length of a String and with the help of length one by one we are transferring the character one by one from one string to another and until length is not become zero in while loop we put the same condition.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<stdio.h>
int main()
{
    char str[50];
    char revStr[50];

    char *strPtr = str;
    char *revPtr = revStr;

    int len = -1;

    printf("Enter The String Without Space:\n\n");
    scanf("%s",str);

    while(*strPtr)
  {
      strPtr++;
      len++;
    }

    while (len >= 0)
  {
      strPtr--;
      *revPtr = *strPtr;
      revPtr++;
      --len;
    }

     *revPtr='\0';
     printf("\n\nReverse String Is \n\n%s",revStr);
    return 0;
}

 

Output:

Enter The String Without Space:

examplesincprogramming

Reverse String Is

gnimmargorpcniselpmaxe

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now