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 the use of operator ^ in C ? and how it works?
why i join syntel?
23 Answers ABC, Syntel, TCS,
Why c is a mother language?
What is the function of multilevel pointer in c?
What are the key features of C?
explain what are pointers?
How can you draw circles in C?
Explain output of printf("Hello World"-'A'+'B'); ?
Write a program to check whether a number is prime or not using c?
write a program for 4 4 3 3 3 3 2 2 2 2 2 2 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 4 4
explain memory layout of a C program
write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?