Given an array of characters, how would you reverse it? How
would you reverse it without using indexing in the array?
Answer / abdur rab
#include <stdio.h>
void reverse ( char* cp_str )
{
char* cp_rev_ptr = NULL;
cp_rev_ptr = cp_str;
while ( ( cp_rev_ptr ) && ( *cp_rev_ptr != '\0' ) )
cp_rev_ptr++;
cp_rev_ptr--;
while ( cp_str < cp_rev_ptr ) {
*cp_str ^= *cp_rev_ptr ^= *cp_str ^=
*cp_rev_ptr;
cp_str++;
cp_rev_ptr--;
}
}
int main ( int argc, char* argv [] )
{
char array [] = {"dlroW olleH"};
printf ("\nBefore :%s", array );
reverse ( array );
printf ("\nAfter :%s", array );
return ( 0 );
}
Output
======
Before :dlroW olleH
After :Hello World
Is This Answer Correct ? | 16 Yes | 5 No |
What is a class?
what is the difference between exit() and _exit() functions?
Write a program in c to print * * * * * *******
Explain the red-black trees?
what is self refrential structure
Can u please send me the exam pattern and also Previous papers to javed123go@gmail.com
Write a program to reverse a linked list in c.
What is the mean of this statement:: if(int i=0 * i=9)
Can we replace the struct function in tree syntax with a union?
What are runtime error?
What is a structure in c language. how to initialise a structure in c?
A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers