C语言 字符串处理函数
2017-05-24 16:15
169 查看
#include <stdio.h> #include <string.h> // strlen void test() { // 测量字符串常量的字符长度(不包括\0这个字符) int len = strlen("李某某"); //printf("%d\n", len); // 测量字符串变量的字符长度 char s[] = "lmj"; //printf("%d\n", strlen(s)); char s1[] = {'m', 'j'}; // 结果是5 内存中的存储是:mjlmj\0 printf("%d\n", strlen(s1)); } // strcpy void test1() { char left[10]; // 拷贝"itcast"到数组left中 strcpy(left, "itcast"); printf("%s", left); } // strcat void test2() { char left[10] = {'m', 'j', '\0', 'i', 't', 'c', 'a', '\0'}; // 从left的第一个\0开始拼接ios这个字符串 // 拼接的结果是:mjios\0 strcat(left, "ios"); // 拼接的结果:mjios\0a\0 printf("%s", left); } // strcmp void test3() { int delta = strcmp("abc", "aac"); printf("%d", delta); } int main(int argc, const char * argv[]) { test3(); return 0; }
相关文章推荐
- 更安全的C语言字符串处理函数
- C语言字符串处理函数总结
- C语言字符串处理的几个常用函数
- c语言字符串处理函数大全
- C语言字符串处理的库函数
- C语言字符串处理函数
- Strsafe.h:更安全的C语言字符串处理函数
- 字符串处理函数gets()、puts()、strcmp()、strlen()、strcpy()、strcat()-C语言
- C语言中字符串处理函数拾锦
- C语言中的几个字符串处理函数: strcat, strncat, strcpy, strncpy, strlen
- C语言中字符串处理函数拾锦
- C语言常用字符串处理函数
- C语言中字符串处理函数拾锦
- Strsafe.h安全的C语言字符串处理函数
- [收藏备用]C语言字符串处理函数
- C语言和C++下字符串处理函数总结
- C语言 字符及字符串处理函数
- c语言中常字符串处理的函数
- C语言字符串处理函数
- 字符串处理函数strlen、strcpy、strcat、strcmp和convert的C语言实现