Ejemplo n.º 1
0
int test_strncat(char* src, char* dest, int size, int log)
{
	char *return1, *return2;
	char dest1[20], dest2[20];

	strcpy(dest1, dest);
	strcpy(dest2, dest);

	return1 = strncat(dest1, src, size);
	return2 = new_strncat(dest2, src, size);

	if(log)
	{
		printf("strcat:     src: %s  dest: %s  size: %d return: %s\n", 
				src, dest1, size, return1);
		printf("new_strcat: src: %s  dest: %s  size: %d return: %s\n", 
				src, dest2, size, return2);
	}

	return strcmp(dest1, dest2)==0 && strcmp(return1, return2)==0;
}
Ejemplo n.º 2
0
/*
*	var: char* & const char*
* return: char*
*	Adds the string contained in source to the end of the string contained in destination. The values in destination are modified, but a pointer to destination is also returned.
*/
char* new_strcat(char* destination, const char* source)
{
	new_strncat(destination, source, INT_MAX); //calls new_strncat with the n parameter as INT_MAX so it goes until a NULL character
}