how to reverse string "Hello World" by using pointers only.
Without any temp var
Answer Posted / 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 View All Answers
What is function prototype in c language?
How can you tell whether a program was compiled using c versus c++?
program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)
Explain how can I make sure that my program is the only one accessing a file?
What is use of #include in c?
Why c is called free form language?
Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?
An arrangement of information in memory in such a way that it can be easily accessed and processed by a programming language a) string b) data structure c) pointers d) array
What are local static variables? How can you use them?
Explain how can I convert a number to a string?
What are the usage of pointer in c?
What is the default value of local and global variables in c?
What is modeling?
Was 2000 a leap year?
what is the format specifier for printing a pointer value?