Why do we need to put a &
operator in scanf()
for storing values in an integer array but not while storing a string in a char array?
int a[5];
for(i=0;i<5;i++)
scanf("%d",&a[i]);
but
char s[5]; scanf("%s",s);
We need to pass in the address of the place we store the value, since array is a pointer to first element. So in the case with int/float arrays it basically means (a+i)
.
But whats the case with strings?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…