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; }