Question
Use of memset and memcpy
Posted on September 26, 2011 at 11:27
Hello,
I am using STM32-P103 to decode NMEA sentences with some codes that they were already written and making small changes in them and I have notice that the use of functions like memset and memcpy makes the system go into an infinite loop where it can't come out. Is there a way to make it work with out getting it stuck there or an equivalent function to it? I am using Eclipse and C++. &sharpinclude <stdio.h> &sharpinclude <stdlib.h> &sharpinclude <string.h> char* sixbit2bin(char* sixbit, int length) { int i = 0; int value = 0; static char ret[MAX_RET]; char tmp[10]; memset(ret,0,sizeof(ret)); if(length<=0) return NULL; for(i=0;i<length;i++) { value = sixbit[i]+40; if(value>128) value+= 32; else value+= 40; memset(tmp,0,sizeof(tmp)); memcpy(&ret[6*i],&tmp[2],6); } ret[6*i] = '\0'; return ret; } This is one of the functions in which it gets stuck... Sorry if this is a stupid question but I can't find my way out of the problem. Thanksss #fault-handler #fault-handler #fault-exception