c语言 9-2

1、

#include <stdio.h>

int main(void)
{
    char s[] = "ABC";
    printf("begin: %s\n", s);
    
    int i;
    for(i = 0; i < 4; i++)
    {
        s[i] = '\0';
    }
    
    printf("end: %s\n", s);
    
    return 0; 
}

 

 

2、

#include <stdio.h>

int main(void)
{
    char s[] = "ABC";
    printf("begin: %s\n", s);
    
    s[0] = '\0';
    
    printf("end: %s\n", s);
    
    return 0;
}

 

3、

#include <stdio.h>

int main(void)
{
    char str[] = "abcd";
    printf("begin: %s\n", str);
    *str = 0;
    printf("end: %s\n", str);
    
    return 0;
}

 

posted @ 2021-05-25 18:26  小鲨鱼2018  阅读(99)  评论(0编辑  收藏  举报