Bug Four

There is something terribly wrong with this pack/unpack scheme. At least one of the functions doesn't work properly. Which one, and why not?

#include <iostream>

#include <string.h>

using namespace std;

// assume sizeof(char) == BYTE

void pack(void **vpp, char *str, int i) {
	
	*vpp = new char[strlen(str) + 1 + sizeof(int)];
	void *vp = *vpp;
	while (*str) {
		*(char *)vp = *str;
		vp = ((char *)vp + 1);
		str++;
	}
	*(char *)vp = *str;
	vp = ((char *)vp + 1);
	memcpy(vp, (void *)&i, sizeof(int));

}

void unpack(void *vp, char **str, int &i) {

	*str = new char[strlen((char *)vp) + 1];
	char *cp = *str;
	while (*(char *)vp) {
		*cp = *(char *)vp;
		cp++;
		vp = ((char *)vp + 1);
	}
	*cp = 0;
	vp = ((char *)vp + 1);
	i = *(int *)vp;

}

int main() {

	return 0;

}




Hint
Answer