basic question.
why in the printf statement we have the variable and in the scanf we have the address of the variable.
is there a reason behind this?
basic question.
why in the printf statement we have the variable and in the scanf we have the address of the variable.
is there a reason behind this?
printf only needs a copy of the values.
scanf needs the address so it can make a change to the variables
Because scanf() needs to write answers back into those variables, so it needs to know where to store the answers
printf() doesn't know about the variables at all, it only knows about the values passed as parameters.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
ok, so printf is given the bare minimum.
thanks, that make sense