copy string ..

Hello ..
I want to copy the string from orig to dest. by the function ypcrts.. so what is the problem in my code.. thx a lot


#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <stdio.h>
#include<string.h>
using namespace std;

char ypcrts(char* dest, char *orig)
{
char c;
char *p;
int i=0;
for (p = orig + strlen(orig)-1 ; dest < orig; dest+i, p--)
{
i++;

c = *orig;

*dest = *p;

*p = c;
}
return *dest;
}
int main()
{

char *ch1;
ypcrts(ch1, "Hello");

printf("%s", ch1);

return 0;
}
so I want to get .... ch1=olleH
@ ne555..

I'm beginner... is there sth not clear in my code ...???
You are not doing what you think you are doing.
So comment your code with the intention (please use code tags)
Topic archived. No new replies allowed.