简单的字符串处理函数_C语言

字符串数组

 

// Code file created by C Code Develop

#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "stdlib.h"

// 字符串数组常用的函数

int main(){
    char st[30];
    // scanf( "%s", st);
    memset(st, 0, sizeof(st));  // 初始化数组,全部赋0
    gets(st); //获取一个字符串
    puts(st); //输出一个字符串
    
    char stt[10];
    strcpy(stt, "guanyi");  // 给字符串赋值
    strcat(st, stt);  // 连接两个字符串st和stt 
    // puts(st);  
    int lenth = strlen(stt);  // 获取字符串的长度
    
    return 0;
}

 

posted @ 2021-11-23 16:31  def_Class  阅读(36)  评论(0编辑  收藏  举报