Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Given an array of characters, how would you reverse it? How
would you reverse it without using indexing in the array?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between scanf and fscanf?

1209


How to write a code for implementing my own printf() and scanf().... Please hep me in this... I need a guidance... Can you give an coding for c... Please also explain about the header files used other than #include...

5408


Explain how do you print only part of a string?

1171


What does s c mean on snapchat?

1048


a c code by using memory allocation for add ,multiply of sprase matrixes

2753


Is main a keyword in c?

1089


What is conio h in c?

1008


What is variable declaration and definition in c?

866


Is main an identifier in c?

1094


What language is c written?

985


What are the advantage of c language?

1010


What is a null pointer in c?

1137


How do c compilers work?

1059


What is the difference between far and near ?

1161


write a progrmm in c language take user interface generate table using for loop?

2004