字符串函数

 1 #include <iostream>
 2 #include <algorithm>
 3 #include <cstdio>
 4 #include <string>
 5 #include <string>
 6 #include <cstring>
 7 #include <map>
 8 #include <utility>
 9 using namespace std;
10 char  s[10],t[10];
11 int  main()
12 {
13     /* 
14     scanf("%s%s",s,t);
15     if(!strcmp(s,t))//比较s,t 
16 {
17     cout<<"yes
";
18 }
19 else{
20     if(!strncmp(s,t,2)){//仅仅比较前2个字符 
21         cout<<"yes
";
22     } 
23 else     cout<<"no
";
24 }
25 */
26 /*
27   scanf("%s%s",s,t);
28   //strcpy(t,s);
29   
30        dafsg
31     fw
32     dafsg
33     
34   strncpy(t,s,2);
35        dwafb
36     df
37     dw
38   printf("%s
",t);
39   
40     */
41     scanf("%s%s",s,t);
42     //strcat(s,t);
43     arfweg
44     sge
45     arfwegsge
46     strncat(s,t,2);
47     FEGdg
48     fed
49     FEGdgfe
50 
51     
52     printf("%s
",s);
53     return  0;
54 }
原文地址:https://www.cnblogs.com/tingtin/p/10464444.html