Cause
Today, I found that a code that does not call any c library function to achieve String concatenation is too complicated for many people to write, and the linked list is used up, as long as you know that the final cutoff character of the string is '\ 0 '.
Description:
Without using any string library function, we can accept two strings without redundancy and then connect them without redundancy.
Input:
Each line contains two strings and the length cannot exceed 100.
Output:
Multiple groups of test data may exist. For each group of data,
Without using any string library function, we can accept two strings without redundancy and then connect them without redundancy.
Output the connected string.
Sample input:
Abc def
Sample output:
Abcdef
Go directly to my AC code
[Cpp]
# Include <stdio. h>
# Include <stdlib. h>
Void contact (char * str, const char * str1, const char * str2 );
Www.2cto.com
Int main ()
{
Char str [2, 201], str1 [101], str2 [101];
While (scanf ("% s", str1, str2 )! = EOF)
{
Contact (str, str1, str2 );
Printf ("% s \ n", str );
}
Return 0;
}
/**
* Description: String concatenation Function
*/
Void contact (char * str, const char * str1, const char * str2)
{
Int I, j;
For (I = 0; str1 [I]! = '\ 0'; I ++)
{
Str [I] = str1 [I];
}
For (j = 0; str2 [j]! = '\ 0'; j ++)
{
Str [I + j] = str2 [j];
}
Str [I + j] = '\ 0 ';
}