Program to reverse given string
#include<stdio.h> #include<string.h> main() { char str[50],ch,*ptr1,*ptr; int i,j; printf("enter a string\n"); scanf("%[^\n]s",str); for(i=0,j=strlen(str)-1;i<j;i++,j--) { ch=str[i]; str[i]=str[j]; str[j]=ch; } printf("%s",str); printf("\n"); }OutPut:
madan@madan-Lenovo-G570:~/madan$ cc array9.c madan@madan-Lenovo-G570:~/madan$ ./a.out enter a string welcome madan reddy hyderabad dabaredyh ydder nadam emoclew