本文介绍了C语言中的Char数组和scanf函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我期望在以下代码中出现错误,但我没有.我没有使用&
符号.我也在编辑char
s的数组.
I expected to get errors in following code, but I did not. I did not use &
sign. Also I am editing array of char
s.
#include <stdio.h>
int main()
{
char name[10] ="yasser";
printf("%s\n",name);
// there is no error ,
// trying to edit array of chars,
// also did not use & sign.
scanf("%s",name);
// did not use strcpy function also.
printf("%s\n",name);
return 0;
}
推荐答案
scanf("%s",name);
完全可以,因为name
已经是字符数组的地址.
That's totally ok as name
is already the address of the character array.
这篇关于C语言中的Char数组和scanf函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!