Sorry i haven't read the notes before. So i am sending it again.When I debugging my program, the following function is not working proper. Actually this function runs properly on C, but not in Keil. There are 2 different problems occured. 1) strcat cannot add 2 strings. after strcat no any results. 2) once i merge this function into main function, the second memmmove is also working inproper. The pointer of T and CngStr are becoming the same. How can I solve it?
void main() { SerialInit(); printf("After Function %s\n",Change("0912cf4f3c")); return; } char *Change(char *Str){ char *CngStr; char *T; char *Change(char *Str){ char *CngStr; char *T; CngStr = (char *) malloc (strlen(Str)+2); T = (char *) malloc (strlen(Str)); strcpy(CngStr,""); strcpy(T,""); memmove(CngStr,Str+2,8); CngStr[8] ='\0'; memmove(T,Str,2); T[2] ='\0'; strcat(CngStr,T); free(T); return(CngStr); }
"Sorry i haven't read the notes before." Before posting to any forum, you should always make the time to read the instructions, etc. "So i am sending it again." It would've been more helpful if you'd continued in your original thread, rather than start a new one on exactly the same subject. http://www.keil.com/forum/docs/thread7262.asp "this function runs properly on C, but not in Keil" That still makes no sense! What do you mean? 'C' is a programmaing language - you can't "run" anything "on 'C'" Your program uses malloc. Apart from this generally being not a good thing in embedded systems, have you initialised the heap?