Basic and Advance C Question:

Download Job Interview Questions and Answers PDF

Why does the call char scanf work?

C Programming Interview Question
C Programming Interview Question

Answer:

Why does the call
char s[30];
scanf("%s", s);

work? I thought you always needed an & on each variable passed to scanf.

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.

Download C Programming Interview Questions And Answers PDF

Previous QuestionNext Question
Why doesnt this code work?Why doesnt the call scanf work?