how to reverse string "Hello World" by using pointers only.
Without any temp var



how to reverse string "Hello World" by using pointers only. Without any temp var..

Answer / aravind

#include<stdio.h>
char reverse(char *, char *);
int main()
{
char a[]="hello"
char b[]="world";
gets(a,b);
puts(a); /*displays Hello world*/
reverse(a,b);

char reverse(char *ptr, char *ptr1)
{
int i,j;
for(i=0;i!='\0';i++)
{
printf("%s",*ptr);
ptr++;
}
for(j=0;j!='\0';j++)
{
printf("%s",*ptr1);
ptr1++;
}
gets(*ptr1,*ptr);
puts(*ptr1); /*displays world hello*/
}

Is This Answer Correct ?    0 Yes 10 No

Post New Answer

More C Interview Questions

How would you rename a function in C?

0 Answers   Tech Mahindra,


What is an object?

5 Answers  


how can f be used for both float and double arguments in printf? Are not they different types?

0 Answers  


what is ANSI and ISO

7 Answers   HCL,


What are extern variables in c?

0 Answers  






Compare array data type to pointer data type

0 Answers  


how to create duplicate link list using C???

0 Answers  


The differences between Windows XP and Windows Visa

8 Answers   HCL,


Which of these functions is safer to use : fgets(), gets()? Why?

0 Answers  


write a program to generate 1st n fibonacci prime number

12 Answers  


What does static variable mean in c?

0 Answers  


What does void main return?

0 Answers  


Categories