C Program to TO REVERSE THE GIVEN STRING using Pointers

C Program to TO REVERSE THE GIVEN STRING using Pointers


#include
#include
void strev(char *str1, char *str2);
void main()
{
char *str1, *str2;
clrscr();
printf("\n\n\t PLZ ENTER A STRING...: ");
gets(str1);
strev(str1,str2);
printf("\n\t YOUR THE REVERSED STRING IS...: ");
puts(str2);
getch();
}
void strev(char *str1, char *str2)
{
int i = 0, len = 0, r = 0;
while(*(str1+len)!='\0')
len++;
for(i=len-1; i>=0; i--)
{
*(str2+r) = *(str1+i);
r++;
}
*(str2+r) = '\0';
}





Related Links :

2 comments:

  1. A C program to perform the following?
    The program should meet the following objectives:
    1. To determine the number of items purchased per customer (it should be in the range of 1-10)
    2. To input price per item.
    3. To determine if there are new customers and repeat steps 1 and 2.
    4. To calculate and output total expenses spent by all customers visiting the shop on a particular day
    5. To determine and output the number of customers
    6. To calculate and output the average spent by a customer

    PLEASE REPLY

    ReplyDelete
  2. PLSEND THE LINK TO GREETINGSONLY(at)Gmail[dot]com

    ReplyDelete


If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE


More Useful Topics...

 

History Of C..

In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.

My 1st Program...


#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}

Next Step...


#include
#include

void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");

printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");

getch ();

}

Hits!!!