在使用字符串处理函数时都要加上头文件#include <strinng.h>!!!!
1、gets()函数 puts函数()——输入(输出字符串的函数)
gets()函数的形式:gets(字符数组)
gets()函数的作用是从终端输入一个字符串到字符数组,并且得到一个函数值
puts()函数的形式:puts(字符数组)
puts()函数的作用是将一个字符串输出到终端
#include <stdio.h>
#include <string.h>
int main()
{
char s[20];
gets(s); //输入字符串
puts(s); //输出字符串
return 0;
}
2、strcat()函数——字符串连接函数
strcat()函数的形式:stract(字符数组1,字符数组2)
strcat()函数的作用:把两个字符数组中的字符串连接起来,把字符串2连接到字符串1的后面。
#include <stdio.h>
#include <string.h>
int main()
{
char s1[5]="ab";
char s2[5]="cd";
strcat(s1,s2);
printf("%s\n",s1);
return 0;
}