prev up next   top/contents search

comp.lang.c FAQ list · Question 12.12b

Q: Why does the call

char s[30];
scanf("%s", s);
work? I thought you always needed an & on each variable passed to scanf.

A: You always need a pointer; you don't necessarily need an explicit &. When you pass an array to scanf, you do not need the &, because arrays are always passed to functions as pointers, whether you use & or not. See questions 6.3 and 6.4. (If you did use an explicit &, you'd get the wrong type of pointer; see question 6.12.)

prev up next   contents search
about this FAQ list   about eskimo   search   feedback   copyright

Hosted by Eskimo North