Answer to Question #56995 in C for rajashree g.s

Question #56995
write a c program to reverse a character array using pointers
1
Expert's answer
2015-12-18T06:59:32-0500
/* Question#56995, Programming, C */

#include <stdio.h>


void revers( char *str )
{
int n=0; // char counter;
int i=0;
while ( *str!= '\0') // set pointer to the end of the string
{
str++; //poinetr
n++;
}
str--;
for(i=n; i>0; i--) // reverse print of the string
{
printf("%c",*str);
str--;
}
}

int main()
{
char str[64]; //string buffer
printf("Enter string: ");
scanf("%s", str);
revers(str);
printf("\n");
system("PAUSE"); /*sys delay*/
return 0;
}



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS