It would be better if you posted your code in [code][/code] tags from now on; it puts code in a box with a monospaced font:
Code:
#include <stdio.h>
int main(int argc,char** argv)
{
printf("Like this.\n");
return 0;
}
As to your problem, my C is a little rusty, but this is how I see it:
it looks to me like you're trying to assign the pointer to the first element of
ret as the first element of
LOC, not the elements themselves.
i.e.:
char* LOC = new char[501]; dynamically allocates 501 bytes of memory and assigns it to the pointer
LOC.
char ret[501]="This is 501 charecters in my program"; allocates 501 bytes of memory on the heap and fills them with the values of the string "This is 501 charecters in my program".
*LOC = ret; is attempting to assign the
pointer to the
ret array as the
dereferenced value of (i.e. the first element of) the
LOC array, so you're implicitly converting from
char* to
char.
I think what you want to do is
strcpy the contents of
ret into where
LOC points to. Something like:
Code:
char* LOC = new char[501];
char ret[501]="This is 501 charecters in my program";
strcpy(LOC,ret);
I sincerely apologize to all if I'm way off on this…I'm just trying to help.
(…awaits abrasive correction from other, more knowledgable members…)