following program which is expected to print reverse of string provided is printing something else.

include

include<string.h>

using namespace std;
char* strrev(char* ch)
{ char* p=ch;
int end=strlen(ch)-1;
//cout<<ch[end];
//cout<<p;
for(int i=0;i<2;i++,end--);
{
char temp= *(p);
*p=ch[end];
ch[end]=temp;
p++; }
for(int j=0;j<4;j++)
cout<<
ch++;
}
int main()
{ char s[]="yash";
char* str=s;
strrev(str);
//for(int j=0;j<4;j++)
//cout<<*ptr++;
return 0;
}

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories