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()
.
Related Posts:
- waitpid, wnohang, wuntraced. How do I use these
- How to initialize array to 0 in C?
- Sign extend a nine-bit number in C
- Warning: assignment from incompatible pointer type
- C: error: expected ‘)’ before ‘;’ token
- make: Nothing to be done for `all’
- Data argument not used by format strings in C
- execv vs execvp, why just one of them require the exact file’s path?
- difference between
and - expected expression before ‘{‘ token
- Setting std=c99 flag in GCC
- C Vector/ArrayList/LinkedList
- Warning/error “function declaration isn’t a prototype”
- Returning an array using C
- warning: initializer element is not computable at load time
- How to prevent multiple definitions in C?
- error: ‘for’ loop initial declarations are only allowed in C99 mode [duplicate]
- How can you print multiple variables inside a string using printf?
- c – warning: implicit declaration of function ‘printf’
- Flushing buffers in C
- What are 0x01 and 0x80 representative of in C bitwise operations?
- How to make parent wait for all child processes to finish?
- Undefined Reference issues using Semaphores
- What is time(NULL) in C?
- Use of cudamalloc(). Why the double pointer?
- C dynamically growing array
- Why should we check WIFEXITED after wait in order to kill child processes in Linux system call?
- OpenGL — GL_LINE_LOOP —
- How to use EOF to run through a text file in C?
- Incorrect checksum for freed object on malloc
- Valgrind complains with “Invalid write of size 8”
- Expression must be a pointer to a complete object type using simple pointer arithmetic
- What does “request for member ‘*******’ in something not a structure or union” mean?
- Invalid type argument of unary ‘*’ (have ‘int’) Error in C
- Segmentation fault (core dumped) due to fgets – I think
- Why do I get “cast from pointer to integer of different size” error?
- C subscripted value is neither array nor pointer nor vector when assigning an array element value
- What does “request for member ‘*******’ in something not a structure or union” mean?
- Unknown ending signal when using debugger gdb
- Valgrind: invalid read of size 4 -> sigsegv, works fine without valgrind and in visual studio
- error: too few arguments to function `printDay’ (C language)
- Is there a good Valgrind substitute for Windows?
- Difference between sizeof(char) and sizeof(char *)
- Difference between “move” and “li” in MIPS assembly language
- How to empty a char array?
- Assembly x86 – “leave” Instruction
- Undefined reference to main – collect2: ld returned 1 exit status
- How can one see content of stack with GDB?
- What does the term “empty loop” refer to exactly in C and C++?
- Is there a way to have printf() properly print out an array (of floats, say)?
- What integer hash function are good that accepts an integer hash key?
- Proper way to empty a C-String
- malloc(): memory corruption
- How do you allow spaces to be entered using scanf?
- X86 assembly – Handling the IDIV instruction
- How does one represent the empty char?
- Pause screen at program completion in C
- Can I define a function inside a C structure?
- Where is the
header file on Linux? Why can’t I find ? - Difference between fgets and fscanf?
- What is the difference between %g and %f in C?
- Why is the sizeof(int) == sizeof(long)?
- Structure padding and packing
- Lua – Number to string behaviour
- How to allocate array of pointers for strings by malloc in C?
- Reading in double values with scanf in c
- Realloc Invalid Pointer in C
- What tools are there for functional programming in C?
- typedef fixed length array
- “-bash: gcc: command not found” using cygwin when compiling c?
- How to format strings using printf() to get equal length in the output
- “-bash: gcc: command not found” using cygwin when compiling c?
- In C, what exactly happens when you pass a NULL pointer to strcmp()?
- lseek/write suddenly returns -1 with errno = 9 (Bad file descriptor)
- What are the differences between if, else, and else if?
- Should I use printf(“\n”) or putchar(‘\n’) to print a newline in C?
- What do \t and \b do?
- error: struct has no member named X
- strtok segmentation fault
- Invalid write of size 1
- How to solve static declaration follows non-static declaration in GCC C code?
- realloc(): invalid next size when reallocating to make space for strcat on char *
- Constructor for structs in C
- C Error: declaration shadows a local variable — Won’t let me repeatedly replace the value of my float variable
- MIPS to C Translation
- write() to stdout and printf output not interleaved?
- Pointer to 2D arrays in C
- Pointer to a string in C?
- gdb: No symbol “i” in current context
- Cross Platform C library for GUI Apps?
- Implicit function declarations in C
- Pre increment vs Post increment in array
- Convert long long to string in C?
- Using pointer to char array, values in that array can be accessed?
- How can I create a dynamically sized array of structs?
- how to stop a loop arduino
- How to normalize a mantissa
- Level vs Edge Trigger Network Event Mechanisms
- How to use shared memory with Linux in C
- When is it ok to use a global variable in C?