This are my notes in the fields of computer science and technology. Everything is written with ABSOLUTE NO WARRANTY of fitness for any purpose. Of course, feel free to comment anything.

Tuesday, April 14, 2009

Why do you have to pass scanf the address of the variable to write in?

As I was learning C the first time, I remember I was asking this myself... I would have preferred it to return the scanned values, something like:

myVar = scanf("%s") /* don't do this :) */

but of course, in this case (1) you could assign only 1 variable, (2) you would have not had the return value (number of read items)...

Here is some discussion of it: ...

No comments:

About Me

My photo
Hamburg, Hamburg, Germany
Former molecular biologist and web developer (Rails) and currently research scientist in bioinformatics.