(experiment 6) String link function (not used)

Source: Internet
Author: User

Write a string link function yourself: The function is defined as void fun (char A[],char b[]), and it functions by connecting the order of characters in the shape parameter group B to the string of the parameter group A. Note: You cannot use the copy and join functions of a string. For example: A string in Hello,b is 123, and the content in string A is hello123.

The main function enters two strings to the character array str1 and STR2, calls the fun function, implements the connection of the two strings, and outputs the concatenated string.

#include <stdio.h>
#include <string.h>
int main ()
{
void Fun (char A[],char b[]);
Char str1[100],str2[100];
Gets (STR1);
Gets (STR2);
Fun (STR1,STR2);
return 0;
}
void Fun (char A[],char b[])
{
int num1=0,num2=0,i;
Num1=strlen (a);
Num2=strlen (b);
for (i=0;i<=num2;i++)/*i<=num2 instead of i<num2, because the \ in array b is not assigned to array A, the array A does not have an output ending symbol, resulting in garbled output */
{
A[num1++]=b[i];
}
printf ("%s", a);
}

(experiment 6) String link function (not used)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.