problems with memcpy of strings
I am trying to take two strings (message1, message2), assign str1 to message1 if message1 and message2 are empty, assign str2 to message2 if it is empty and message1 is full, and save message 2 over message 1 and put message2 == message3 if both message1 and message2 were full.   I get weird results as shown. But memcpy is not working.  (I know it's my fault somehow.)

INPUT:

    message1: ffW
    message 2: a
    message 3 (2 writes over 1, 3 writes over 2): bbb
     
    MESSAGE 1a: ffW 
    MESSAGE 2a: a_W 
    MESSAGE 1ab: a_W 
    MESSAGE 2ab: a_W 
    MESSAGE 1b: a_W 
    MESSAGE 2b: bbb 

Next one:

    INPUT:
    message1: a
    message2: abcde
    message3: abcdefg
    
    MESSAGE 1a: a�� 
    MESSAGE 2a: abcde 
    MESSAGE 1ab: abcd 
    MESSAGE 2ab: abcde 
    MESSAGE 1b: abcd 
    MESSAGE 2b: abcdefg 


   

     	if (message1[0] == '\0'){
    		memcpy(message1, echoBuffer, sizeof echoBuffer);
                fprintf(stderr, "MESSAGE 1: %s \n", message1);
    }
    	else if (message1[0] != '\0' && message2[0] == '\0') {
    		memcpy(message2, echoBuffer, sizeof echoBuffer);
       	        fprintf(stderr, "MESSAGE 2: %s \n", message2);
    }
    	else if (message1[0] != '\0' && message2[0] != '\0'){
                fprintf(stderr, "MESSAGE 1a: %s \n", message1);
                fprintf(stderr, "MESSAGE 2a: %s \n", message2);
        	memcpy(message1, message2, sizeof message2);
                fprintf(stderr, "MESSAGE 1ab: %s \n", message1);
                fprintf(stderr, "MESSAGE 2ab: %s \n", message2);
    		memcpy(message2, echoBuffer, sizeof echoBuffer);
                fprintf(stderr, "MESSAGE 1b: %s \n", message1);
                fprintf(stderr, "MESSAGE 2b: %s \n", message2);
    	}	
    }

Does anybody know what is wrong?  This problem has been plaguing me.  

I think the messages and echoBuffer are all 100 characters in size.  

problems with memcpy of strings
===

I am trying to take two strings (message1, message2), assign str1 to message1 if message1 and message2 are empty, assign str2 to message2 if it is empty and message1 is full, and save message 2 over message 1 and put message2 == message3 if both message1 and message2 were full.   I get weird results as shown. But memcpy is not working.  (I know it's my fault somehow.)

INPUT:

    message1: ffW
    message 2: a
    message 3 (2 writes over 1, 3 writes over 2): bbb
     
    MESSAGE 1a: ffW 
    MESSAGE 2a: a_W 
    MESSAGE 1ab: a_W 
    MESSAGE 2ab: a_W 
    MESSAGE 1b: a_W 
    MESSAGE 2b: bbb 

Next one:

    INPUT:
    message1: a
    message2: abcde
    message3: abcdefg
    
    MESSAGE 1a: a�� 
    MESSAGE 2a: abcde 
    MESSAGE 1ab: abcd 
    MESSAGE 2ab: abcde 
    MESSAGE 1b: abcd 
    MESSAGE 2b: abcdefg 


   

     	if (message1[0] == '\0'){
    		memcpy(message1, echoBuffer, sizeof echoBuffer);
                fprintf(stderr, "MESSAGE 1: %s \n", message1);
    }
    	else if (message1[0] != '\0' && message2[0] == '\0') {
    		memcpy(message2, echoBuffer, sizeof echoBuffer);
       	        fprintf(stderr, "MESSAGE 2: %s \n", message2);
    }
    	else if (message1[0] != '\0' && message2[0] != '\0'){
                fprintf(stderr, "MESSAGE 1a: %s \n", message1);
                fprintf(stderr, "MESSAGE 2a: %s \n", message2);
        	memcpy(message1, message2, sizeof message2);
                fprintf(stderr, "MESSAGE 1ab: %s \n", message1);
                fprintf(stderr, "MESSAGE 2ab: %s \n", message2);
    		memcpy(message2, echoBuffer, sizeof echoBuffer);
                fprintf(stderr, "MESSAGE 1b: %s \n", message1);
                fprintf(stderr, "MESSAGE 2b: %s \n", message2);
    	}	
    }

Does anybody know what is wrong?  This problem has been plaguing me.  

I think the messages and echoBuffer are all 100 characters in size.  
