Hello.
i'm a newbie and i'm learning c... i had a question in mind in i thought here's a good place to ask...
consider the following piece of code:
my question is that, "logically" i can't understand why for scanf("%d",&b) "&b" has been used, and in scanf("%s",a), "a" without "&" operator has been used? although in printf("int: %d \n",b), b has been used without "&" operator...Code:#include <stdio.h> void main (void) { char a[10]; scanf("%s",a); printf("character: %s \n",a); int b; scanf("%d",&b); printf("int: %d \n",b); }
what's the use of & operator? i would appreciate it if someone could answer this question "logically"...
i asked some of my colleges , and they told me that scanf() only accepts pointers, and when i use scanf() i should use & operator, i asked for reason, they replied that's the way it is... i can't find this answer logical... if that's the case? is it the same thing for printf(). if so, then why printf("int: %d \n",b); is not using "&" operator?



LinkBack URL
About LinkBacks



