Function does work,like I hoped ... char *swapdata (char *destination, char *SourceLine) { char *temp; temp=SourceLine; SourceLine=destination; destination=temp; printf("in function string = %s - %s\n",destination,SourceLine); return temp; } void main(void) { char *p_test1,*p_test2; char test1[] ="test 1"; char test2[] ="test 2"; result[128]; p_test1 = test1; p_test2 = test2; printf("string = %s - %s - %s\n",p_test1,p_test2,result); result=swapdata(p_test1,p_test2); printf("string = %s - %s - %s\n",p_test1,p_test2,result); } Function does not swap ??? Best regards
This works on my C52:
#include <stdio.h> #include <reg52.h> char *swapdata (char **destination, char **SourceLine) { char *temp; temp=*SourceLine; *SourceLine=*destination; *destination=temp; printf("in function string = %s - %s\n",*destination,*SourceLine); return temp; } void main(void){ char *p_test1,*p_test2; char test1[] ="test 1"; char test2[] ="test 2"; char *result; TI = 1; p_test1 = test1; p_test2 = test2; printf("string = %s - %s - %s\n",p_test1,p_test2,result); result=swapdata(&p_test1,&p_test2); printf("string = %s - %s - %s\n",p_test1,p_test2,result); while(1) ; }
Ignore the lines:
#include <reg52.h> TI = 1;