Howdy, Stranger!

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

Categories

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

Manish BhattiManish Bhatti indiaMember Posts: 1

#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;
}

Tagged:
Sign In or Register to comment.