I have read and read, but I cant seem to find the answer...
I have written a program that calls this function:

Code:
char *ConvertToBinaryString(Ciphertext *cipher)
{
	int i;
	char *output;

	output = (char *)malloc(sizeof(char));
	
	strcpy(output, "");

	for(i=0; i<64; i++)
	{
		if(cipher->cipher[i].bit == 1)
			strcat(output, "1");
		else
			strcat(output, "0");

	}

	return output;
}//End of ConvertToBinaryString
In my main I call the function that calls the above function twice, sequentially. The first time, the function that calls the above function executes, everthing is fine and I get the desired output. The second time I call the function that calls this function, the malloc statement at the start of this function returns a NULL. I have tried time and time again to get around this. Does anyone have any ideas?

I have tried using preset array size (the output will always be a 64 byte string), but to no avail. This function comes at the end of the function that calls it, and I have stepped through it a thousand times. Malloc always returns NULL the second time I call the function. Thanks in advance.