The strrev() function is used to reverse the selected string value.
STRREV() FUNCTION EXAMPLE
#include<stdio.h>
#include<string.h>
#include<conio.h>
void main()
{
clrscr();
char s[60];
puts("Enter any sentence: ");
gets(s);
printf("The reversed string is : %s", strrev(s));
getch();
}
----------------------------
OUTPUT
----------------------------
Enter any sentence:
Computer
retupmoC
C PROGRAM TO REVERSE STRING WITHOUT STRREV() FUNCTION
#include<stdio.h>
#include<string.h>
#include<conio.h>
void main()
{
clrscr();
char s[60];
int i, L
puts("Enter any sentence: ");
gets(s);
// Loop to print string in reversed form.
for(i=L; i>=0; i--)
{
printf("%c",s[i]);
}
getch();
}
OUTPUT
----------------------------
Enter any sentence:
Computer
retupmoC
STRCPY IN C >>
No comments:
Post a Comment