Hi ,
I am trying to reverse a string using pointers.I am able to reverse a sting like this:
My Reverse Program --> margorp esrever em
But I want it word by word.
Program Reverse My.
#include <stdio.h>
#include <string.h>
char str[50]="Reversing a string using XOR";
char strb[50];
char* strc;
char strC[50];
char* rev(char* str)
{
char *ptr;
//ptr = str;
char *ptrA;
ptr = strb;
ptrA= str + strlen(str)-1;
printf("i am inside the function %s \n",ptrA);
int start = 0;
while( ptrA>=str )
{
// printf("i am inside the function while %s\n", ptrA);
if (ptrA==' ')
{
printf("oh...i found a space");
}
*ptr++ = *ptrA--;
}
*ptr = '\0';
printf("i am inside the *********** function %s \n",ptrA);
return strb;
}
int main()
{
// puts(rev(str));
strc = rev(str);
puts(strc);
printf("Reverse String is %s \n",strc);
return 0;
}