All Questions
116
questions
0
votes
2
answers
156
views
Why is STDIN open by default for programs running in SystemD?
I have an if-statement at the top of a C main method, which checks if STDIN is open. If it is open, the program prints an error and exits. This is mainly for documentation reasons. I don't want ...
0
votes
1
answer
154
views
How the python interpreter receives and outputs data?
What happens when I write print('Something')?
Does the interpreter work directly with the system I / O means, or does it use some kind of system API, which gives information that something needs to be ...
0
votes
0
answers
137
views
How to input() after reading stdin in python?
This simple code:
#!/usr/bin/env python3
import argparse
import socket
import shlex
import subprocess
import sys
import textwrap
import threading
def execute(cmd):
cmd = cmd.strip()
if not ...
0
votes
0
answers
26
views
writing out to stdout and followed by reading from stdin doesn't write to stdout in the same line - C Programming [duplicate]
I'm writing a program where it involves creating a prompt that reads input from stdin. The actual code is large and the scope of this problem resides in the following snippet of code. Here's a simple ...
1
vote
1
answer
136
views
Ruby: "Parasite" characters with gets after pressing arrow key on getch
I've been looking into a way to implement a "Press any key to continue" feature into my program, and figured I'd use $stdin.getch.
Seems to work in most cases, but I noticed that if I ...
3
votes
2
answers
229
views
Reading everything currently entered in stdin
I want to read everything that is on stdin after 10 seconds and then break. The code I've been able to write so far is:
#include <stdio.h>
#include <stdlib.h>
int main() {
sleep(10);
...
0
votes
1
answer
492
views
Reading from STDIN with the read() function in c: a clarification
I'm trying to write the simplest, lowest level, most basic way to read from STDIN and do something with what I read when I reach a certain size (let's say 16 chars?).
Consider this snippet:
#include &...
0
votes
0
answers
24
views
printf prints text two times in while loop even after fflushing stdin after scanf [duplicate]
So, this is the code, it takes input, inserts/sorts depending on choice, now the problem is in the input part, Somehow getchar misses a cycle every time. I know this is related to stdin and ENTER but ...
-3
votes
1
answer
355
views
how to parse line into number and string? [closed]
I would like to parse a sentence beginning with a number:
2 random sentece.
5 another one.
8 this is really long sentence.
Into int number holding the beginning number and the rest in std::string ...
0
votes
1
answer
385
views
Strange buffering behavior in termios/stdlib
I'm trying to disable buffering on my program's input/output so that characters are transmitted and received ASAP, but I'm not seeing the results I'd expect based on what I've read about buffering in ...
1
vote
1
answer
58
views
When using the open command, and O_CREAT, it is appending a "?" to the end of the file name, how do I remove this?
So I am using the open function in C to open a target file, and if it does not exist, I will create it. I am redirecting stdout from the terminal into this file. When I run my program, it creates a ...
1
vote
1
answer
369
views
How to implement blocking iterator over stdin?
I need to implement a long-running program that receives messages via stdin. The protocol defines that messages are in form of length indicator (for simplicity 1 byte integer) and then string of a ...
1
vote
1
answer
390
views
Reading lines from input
I'm looking to read from std::in with a syntax as below (it is always int, int, int, char[]/str). What would be the fastest way to parse the data into an int array[3] and either a string or char array....
2
votes
3
answers
1k
views
Input Redirection in C - Using fgets to read from stdin not working
I have an assignment where I need to create a shell in C. One of the specifications is to implement input redirection when the redirection symbol is entered ('<'). Then I am attempting to read the ...
3
votes
1
answer
215
views
python - force input() to read newline character from a different thread and forward execution
I want to figure out a way to programmatically avoid the builtin input() method stopping and waiting for user input.
Here is a snippet showing what I'm trying to do:
import sys
from threading import ...