1. Concatenation of strings
Functions using C char *strcat (char *str_des, char *str_sou);
Str_sou the string after the string str_des (placed between the last character of the Str_des and "the").
Be careful not to cross over, use strlen (input) function to find string length and then stitching.
2. Segmentation of strings
Use C's function char *strtok (char *str_sou,constchar *str_sep);
Str_sou: The string to be split. STR_SEP: Split symbol.
First Call: temp = strtok (input, a); (Input: String, a: delimiter);
Called after: temp = Strtok (NULL, a);
Temp is the string to be split.
3. Demo
#include <string.h>
#include <stdio.h>
int main (void)
{
Char input[16];
Stitching, A: dividing a symbol; B,c:2 a string
Char *a = ":", *b = "1", *c = "I am QY";
printf ("stitching before the string (garbled):%s\n", input); Input is not initialized, the print is garbled
strcpy (INPUT,B);
strcat (Input,a);
strcat (INPUT,C);
printf ("Concatenation of Strings:%s\n", input);
Length: printf ("The length of the string after concatenation:%d\n", strlen (input));
Char *temp;
temp = strtok (input, a);
if (temp)
printf ("String before split symbol:%s\n", temp);
temp = Strtok (NULL, a);
if (temp)
printf ("String after split symbol:%s\n", temp);
return 0;
}