Answer to Question #2524 in Action Script | Flash | Flex | ColdFusion for saleem

Question #2524
Why we use ampersand in scanf but dont use ampersand in assignment operator on left hand side though we are giving it a value?
Expert's answer
The function "scanf" can have many arguments and every argument can be different: int, float, char etc. Naturaly each type of argument must be read its own way. But at the same time the function "scanf" is the same, so function "scanf" uses arguments' adresses instead of arguments (adress of any argument is always the same type - non-specified pointer). This is good idea of unification. To know of what type is& some argument's adress the function "scanf" uses specification such
as "%i" for int or "%f" for float. We can get adress using ampersand.

Assignment operator looks the same for every type of argument, but it's not true: for every type there is its own assignment operator,
don't metter that it always looks the same (as a sign "="). Thus there is no any cause to use ampersand, compiler knows what exact assignment operator to use. If we try to write something like following:
int i=0,j=1;
then we will get an error. This is because we tryed to assign some value not to the variable, but we tried to set its adress.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

New on Blog