Run-Time Check Failure #2 - Stack around the variable 'g' was corrupted.
my string concatenating function:
int main (void)
strcat_s539(g, 10, "CHINA");
Perhaps someone can spot my problem?
int strcat_s539 (char *dest, unsigned size, const char *source)
int i; //variable counter
int j=0; //counter for concatenating w/o nesting
char *temp; //variable to hold a temporary array to copy from source to dest.
temp = malloc(size*sizeof(source)); //allocate array for temporary
if (dest=='\0' || source=='\0' || (strlen539(dest)+strlen539(source))>(size-1)) //test for NULL and size big enough
for (i=0; i<=strlen539(source); ++i)
temp[i] = source[i];
for (i=(strlen539(dest)); i<=(strlen539(dest)+strlen539(source)); ++i, ++j)
dest[i] = temp[j];
strlen539 is just a handwritten function that does the same thing as strlen if anyone is wondering b.t.w. and the function actually returns the correct concatenated string: FINECHINA... its just that it brain damages the computer anyway so something is wrong somewhere.