Validate max integer in scanf

I want to read a int from stdin but I want to validate if the user exceeds the int max value. How can I do it? int n; scanf("%d", &n); scanf reads the decimal input and stores in the int,...

Haskell: read input character from console immediately, not after newline

I've tried this: main = do hSetBuffering stdin NoBuffering c <- getChar but it waits until the enter is pressed, which is not what I want. I want to read the character immediately after user...

Why is “while ( !feof (file) )” always wrong?

What is wrong with using feof() to control a read loop? For example: #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { char *path = "stdin"; FILE *fp = argc > 1 ?...

fgets doesn't work after scanf

#include <stdio.h> #include <string.h> #include <ctype.h> void delspace(char *str); int main() { int i, loops; char s1[101], s2[101]; scanf("%d", &loops); while (loops--) { ...

Why are fputc and fputs outputs not immediately noticable?

I am writing a C program, but not seeing the results of either an fputc or fputs call. I need help with understanding why that is happening. #include <stdio.h> int main(void) { FILE *stream; ...

How do I read console input / stdin in Dart?

How do I read console input from stdin in Dart? Is there a scanf in Dart?

Read a character from standard input in Go (without pressing Enter)

I want my app to show: press any key to exit ... And to exit when I press any key. How can I achieve this? Note: I have googled but all of what I've found needed to press Enter at the end. I want...

sys.stdin.readline() and input(): which one is faster when reading lines of input, and why?

I'm trying to decide which one to use when I need to acquire lines of input from STDIN, so I wonder how I need to choose them in different situations. I found a previous post...

aio_read from STDIN_FILENO returns EAGAIN in OS X

When I compile this code in OS X: #include <unistd.h> #include <iostream> #include <memory> #include <aio.h> #include <sys/stat.h> #include <fcntl.h> using namespace std; int main(int,...

Logstash Geoip is not working

I'm trying to set long and lat for the kibana Bettermap using Geoip. I'm using Logstash 1.4.2 and Elasticsearch 1.1.1 and the following is my configuration file: input { stdin { } } filter { ...

Why is this Haskell program so much slower than an equivalent Python one?

As part of a programming challenge, I need to read, from stdin, a sequence of space-separated integers (on a single line), and print the sum of those integers to stdout. The sequence in question...

Validate the type of input in a do-while loop C

Basically, I need to ensure that input is an integer, like so: do { printf("Enter > "); scanf("%d", &integer); } while (/* user entered a char instead of an int */); I have tried various...

How to do polymorphic IO from either a File or stdin in Rust?

I'm trying to implement a "polymorphic" Input enum which hides whether we're reading from a file or from a stdin. More concretely, I'm trying build an enum that will have a lines method that will...

Python Subprocess: Unable to Escape Quotes

I know similar questions have been asked before, but they all seem to have been resolved by reworking how arguments are passed (i.e. using a list, etc). However, I have a problem here in that I...

How to take two consecutive input with the readline module of node.js?

I am creating a program to take input of two numbers from the command line and then showing there sum in node.js. I am using readline module to take stdin. Below is my code. const readline =...

How to run a background process and do *not* wait?

My goal is simple: kick off rsync and DO NOT WAIT. Python 2.7.9 on Debian Sample code: rsync_cmd = "/usr/bin/rsync -a -e 'ssh -i /home/myuser/.ssh/id_rsa' {0}@{1}:'{2}' {3}".format(remote_user,...

Why is Internal memory in java Native Memory Tracking increasing

My application is running in a docker container, it use scala and use "OpenJDK 64-Bit Server VM (build 25.102-b14, mixed mode)", its Xmx is set to be 16GB and container memory limit is 24Gb, after...

How to know when there is input through the terminal pipe line on C++ 11?

How to know when there is input through the terminal pipe line on C++ 11? I may call my program like this: 1. ./main solved.txt 2. cat unsolved.txt | ./main 3. cat unsolved.txt | ./main...

can't connect TCP socket between Ubuntu and Windows

I made a server socket in Ubuntu and a client socket in Windows but the connection is refused on the server. It says: "Connection refused". I'm using Ubuntu 16.04 LTS and Windows 10. Both sockets...

Getting 'OSError: [Errno 2] No such file or directory' on popen when trying to run mypy

Hello stack overflow users, I'm having a great deal of difficulty trying to get mypy to work correctly with Popen. Essentially I'm writing a test suite that utilizes mypy but cannot seem to get...

Heroku Postgres - Import from CSV via CLI

Having a beast of a time trying to find a solution to trying to import a CSV (local on my machine - don't ask - this is a customer issue and it's the only way I can get data from them at the...

laravel artisan use of undefined constant STDIN - assumed 'STDIN' infinite loop

I am using laravel 5.6 and have the problem, when I use the command "php artisan vendor:publish" in the console, I get the following error: [ERROR] Use of undefined constant STDIN - assumed...

In shell pass results of "python -m SimpleSTTPServer" to pipe

I am trying to send the outputs of a Python CLI "SimpleHTTPServer" command to a pipe, in order to grep the results. But it seems that the first line of the output is not being passed to the pipe,...

Missing Converter handling for full class name=org.postgresql.util.PGobject, simple name=PGobject

There is a column of geometry type in my postgres table. I checked that the rest of the columns worked fine postgres-> logstash-> elasticsearch. However, I am not sure how to cast the geometry...

pgadmin 4, import csv, error code 1, no error message

I am trying to import csv into pgadmin4. I keep getting an error code 1, but no details. the command log: 2021-02-19 01:47:08.718 UTC [88] STATEMENT: COPY public.flights ( year, quarter, month,...

Passing bytes to ffmpeg in python with io

Sorry, new to stackoverflow Just wondering if it's possible to pass byte data from io. I'm trying to extract frames from a gif with ffmpeg then use Pillow to resize it. I know you can extract...

Python does not find the Brownie file

I'm following a tutorial on Solidity and Python (for reference https://www.youtube.com/watch?v=M576WGiDBdQ&t=5447s). I'm at the stage where Python and Brownie have been installed and running...

Rails 7 asset pipeline SassC::SyntaxError with Tailwind

I'm working on getting a new Rails 7 project deployed to production (trying on both Heroku and Render.com) and am getting the following error during build: $ tailwindcss -i...

Provided region_name '"$region"' doesn't match a supported format for Windows (CMD)

I am trying to deploy ECS using Terraform and it's throwing the above error while I am Provisioning the ECR this is happening. It tried removing the double quotes, then enabled trace for...

Paramiko authentication fails with "Agreed upon 'rsa-sha2-512' pubkey algorithm" (and "unsupported public key algorithm: rsa-sha2-512" in sshd log)

I have a Python 3 application running on CentOS Linux 7.7 executing SSH commands against remote hosts. It works properly but today I encountered an odd error executing a command against a "new"...

Relevant tags