`

字符串之结束符

    博客分类:
  • C
阅读更多
#include <stdio.h> 
#include <string.h> 

int main(void) 
 {
    char string[10]="123456";
    char *str1     ="abcdefghij";

    printf("string.length=%d\n",strlen(string));
    string[4]='\0';
    printf("string.length=%d\n",strlen(string));
    string[2]='\0';
    printf("string.length=%d\n",strlen(string));

    printf("str1.length=%d\n",strlen(str1));
    str1[6]=0;
    printf("str1.length=%d\n",strlen(str1));
    str1[2]=0;
    printf("str1.length=%d\n",strlen(str1));

    printf("string=%s\n", string);
    printf("str1=%s\n",str1);
    return 0;
 }

string.length=6
string.length=4
string.length=2
str1.length=10
str1.length=6
str1.length=2
string=12
str1=ab
分享到:
评论
1 楼 wuhua 2009-04-19  
不错,学习了

相关推荐

Global site tag (gtag.js) - Google Analytics