0% found this document useful (0 votes)
97 views

Program To Reverse A String Without Using Strrev

This C program demonstrates how to reverse a string without using the strrev() function. It takes a string as input from the user, uses a for loop to copy each character of the string into a second string in reverse order, and outputs the reversed string. Key steps are getting the string length, using a counter from the last index to the first, and adding a null terminator to the second string.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views

Program To Reverse A String Without Using Strrev

This C program demonstrates how to reverse a string without using the strrev() function. It takes a string as input from the user, uses a for loop to copy each character of the string into a second string in reverse order, and outputs the reversed string. Key steps are getting the string length, using a counter from the last index to the first, and adding a null terminator to the second string.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

www.eazynotes.

com

Neeru Babber

Page No. 1

/*

Program to Reverse a String without using strrev()

*/

#include <stdio.h> #include <conio.h> #include <string.h> main() { char string1[10], string2[10]; int i, length; printf("Enter any string:\n"); gets(string1); length = strlen(string1)-1; for(i=0; string1[i]!='\0'; i++) { string2[length]=string1[i]; length--; } string2[length]='\0'; printf("\nThe Reverse of string is:\n"); puts(string2); getch(); }

You might also like