What is stdin in C language?

No, stdin is not “a memory address”.

It’s an I/O stream, basically an operating-system level abstraction that allows data to be read (or written, in the case of stdout).

You need to use the proper stream-oriented I/O functions to read from the stream.

Of course you can read from RAM too, so it’s best to write your own function to require a function that reads a character, then you can adapt that function to either read from RAM or from stdin.

Something like:

int my_scanf(int (*getchar_callback)(void *state), void *state, const char *fmt, ...);

Is usually reasonable. The state pointer is some user-defined state that is required by the getchar_callback() function, and passed to it by my_scanf().

Leave a Comment