C_learn/2_lesson/05_array_char/main.c

16 lines
439 B
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <stdio.h>
int main(int argc, char *argv[])
{
// 定义一个字符数组通过scanf函数输入字符串并输出结果
// 通过赋值""这样的方式可以清除字符数组中的垃圾字符,让每一个元素都是\0
char ch[32] = "";
// 数组名就是当前数组的首地址所以scanf的第二个参数直接传数组名即可
scanf("%s", ch);
printf("ch = %s\n", ch);
return 0;
}