write a c program to reverse a character array using pointers
/* 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!
Learn more about our help with Assignments:
C