Questions tagged [io]

In computing, input/output, or I/O, refers to the communication between an information processing system (such as a computer) and the outside world (possibly a display, an information storage system, or another information processing system).

Filter by
Sorted by
Tagged with
0 votes
0 answers
41 views

C idiom for multi-layer buffered input with processing

I'm writing a bit-level IO code that handles endianness conversion for the short/uint16_t type in the IO subroutines. Here's the code: ...
DannyNiu's user avatar
  • 310
4 votes
2 answers
198 views

Simple GPIO design module in SystemVerilog

I am designing a very crude general-purpose input/output (GPIO) module to provide IO pin control to a RISC-V (like) architecture microprocessor I am currently playing with. This is the code so far: <...
ExpL0siV3Man79's user avatar
1 vote
1 answer
149 views

Multithreaded O_DIRECT file read-and-process program

Here is my code. It reads a file and returns the sum of all the bytes in the file: ...
1f604's user avatar
  • 113
4 votes
2 answers
122 views

Detecting when a user stops typing

I wanted to detect when a user stops typing. I encountered this answer from SO (Not the selected answer, but the second one which seem to be better): https://stackoverflow.com/a/5926782/17746636 But I ...
pileup's user avatar
  • 361
1 vote
3 answers
115 views

C++ getline implementation for custom stdlib

I'm writing my own "standard library". It relies on nothing but syscalls, so I've had to make my own implementations of everything, including getline (...
Fuzzy Muffin's user avatar
8 votes
5 answers
1k views

Python code using *args to print warnings in color

I have this code, which works for the simple tasks I want. But I have questions. ...
aschultz's user avatar
  • 349
6 votes
1 answer
248 views

Crossword puzzle app

I was hoping someone could give me any tips or advice on this program I wrote for my high school class. The point of the program is to create a workable crossword puzzle in the console. If it works ...
Sean Riley's user avatar
7 votes
1 answer
320 views

pure Bash way to trim

How can I improve this? I added the while read loop to handle preceding newlines. ...
Andrew's user avatar
  • 75
2 votes
2 answers
1k views

Capture stdout output of a function call

Are there any major flaws to implement this test helper function? I know that the preferred way (refactoring) would simply make the function to be tested return its value and delegate printing to ...
ojdo's user avatar
  • 420
0 votes
1 answer
115 views

Readlines abstraction for Golang

I've just started learning Golang and was solving some problems which required me to read lines of text from a file. I decided to abstract away the reading part so that I can use Go's ...
smac89's user avatar
  • 1,467
4 votes
2 answers
145 views

Sort todo.txt items by due date in Python 3

I am using the following format for my task management: https://github.com/todotxt/todo.txt Do some stuff +uni due:2022-12-31 Write some paper +uni due:2023-01-10 ...
Tomas's user avatar
  • 43
3 votes
2 answers
1k views

Code lines counter

It is a Windows command line utility for counting lines of code in a source code directory. It will count loc and sloc. I read from a file character by character using fgetc in the CountLines(...) ...
mmj's user avatar
  • 31
3 votes
2 answers
201 views

K&R Exercise 5-11. Modify the "detab" - to accept a list of tab stops as arguments

So far I have reached chapter 5 of the K&R Book, Edition 2 from which I have been learning C. I spent a few days thinking of a solution to this program. I wrote two or three versions of the same ...
jr.çhåvez__07's user avatar
4 votes
2 answers
704 views

generate lottery numbers to store in a text file

I scripted a program in python to generate lottery numbers for user. There are two playing methods: Lotto6aus49: User can choose any 6 numbers out of 49. Eurojackpot: User can choose 5 numbers out of ...
Stephan Koenig's user avatar
2 votes
1 answer
172 views

K&R Exercise 1.22 - "fold" long input lines

Until recently, I decided to go back to Chapter 1 of the K&R Book, Edition 2, to try to "improve" the code I've already done. I have also made some changes since I was limited to just ...
jr.çhåvez__07's user avatar
3 votes
2 answers
224 views

K&R Exercise 4-6. Add commands for handling variables

For the following exercise (Chapter 4, Ex-4.6) of the Book (K&R 2nd Edition): Exercise 4-6. Add commands for handling variables. (It's easy to provide twenty-six variables with single-letter ...
jr.çhåvez__07's user avatar
8 votes
3 answers
824 views

K&R Exercise 3-3. Expands shorthand notations (e.g., a-z to abc..xyz, 0-9 to 012..789)

I have been learning C with K&R Book 2nd Ed. So far I have completed quite a few exercises. For the following exercise (Chapter 3, Ex-3.3): Exercise 3-3. Write a function expand(s1, s2) that ...
jr.çhåvez__07's user avatar
0 votes
1 answer
56 views

streaming / low memory groupby in julia

I am working on a groupby-aggregation function that will work without RAM overflow issues. Essentially, I want it to run as fast as possible, while not necessarily loading the entire data structure ...
chase's user avatar
  • 123
4 votes
2 answers
403 views

Game loop using Future.wait_for to check for input

I started writing this game from scratch yesterday, and I wasn't completely new to C++'s future library. I only use the ...
FLAK-ZOSO's user avatar
  • 143
3 votes
2 answers
85 views

Re-designing c-style Input Output

Re - designing c-style input output [ btw I use printf() and scanf() in the core ] Reasons for redesigning it :- Needs 2 functions for input output [ namely ...
Pear's user avatar
  • 243
4 votes
1 answer
75 views

improved "tee" utility

We have modified the tee program with your suggestions from the previous pull request. Did I implement well? I would like to optimize the program even more, what ...
Mike's user avatar
  • 299
1 vote
1 answer
2k views

Process a binary file by chunk using a read stream in nodejs

I want to process a file chunk by chunk to prevent memory exhaustion. I need to consume the file using a read stream. When trying it, this implementation seems to work fine. I am asking your expert ...
Louis Coulet's user avatar
2 votes
2 answers
135 views

another attempt to implement the tee command

I implemented the tee command from linux. The program implements the -a option Reads standard input until end-of-file, write a ...
Mike's user avatar
  • 299
1 vote
1 answer
138 views

Passwords with C++ Console

I am really, really new to coding in general and especially c++. To get more familiar with c++ I am trying to do a series of projects with c++ console apps. One of my projects is with a database that ...
Jack Parent's user avatar
3 votes
3 answers
147 views

tee: copy standard input to both stdout and a file

I implemented the tee command from linux. The program also handles the -a option for adding text to the end of a file if it ...
Mike's user avatar
  • 299
5 votes
0 answers
533 views

A POSIX getdelim() and getline() implementation for MSVC

Tired of always having problems in reading arbitrary length lines from file under Windows, I tried to write a POSIX getdelim() and ...
Costantino Grana's user avatar
4 votes
2 answers
211 views

Read a file format with mixed CSV and non-CSV content

I have a file format that I need to read which contains blocks of CSV data interspersed by non-CSV (or at least, inconsistent CSV) lines. Other than the very first line of the file (which has comma-...
Ajean's user avatar
  • 263
1 vote
0 answers
56 views

A Command Line To-Do List (CLI) application written in NodeJS

I wrote this code for myself so I can manage my personal to-do list easier. Considering, I spend most of my time in the terminal, it made sense. I have worked on the project as a way of practising my ...
Vinn's user avatar
  • 119
1 vote
1 answer
198 views

C++ intializing and saving mp4 ftyp box struct byte by byte

I'm unsure whether the way I'm performing initialization is recommended, and whether there is a simpler way to save out a struct like the one I'm using. The main points of feedback I'm looking for are ...
Li Brary's user avatar
3 votes
1 answer
60 views

Quickly read numeric input

Do you have any criticisms or corrections or improvements? I need to read only numbers(and this numbers could be from 0 to 1000000) ...
Оля Швенда's user avatar
1 vote
2 answers
154 views

Function that behaves as dup2

I am reading the book Advanced Programming in the UNIX Environment and I have tried to solve the following exercise: Write a function that performs the same actions as ...
Mark's user avatar
  • 449
3 votes
2 answers
304 views

Retry read/write until all bytes are transferred or error occurs

Currently I have a wrapper function for the read/write system calls, the purpose of which is to eliminate partial transfer ...
user avatar
3 votes
1 answer
777 views

get_line(): An alternative implementation of standard C library's getline() function

get_line(): An alternative implementation of standard C library's getline() function. Syntax: char *get_line(int fd, int *error_num); I know that I can declare/...
user avatar
7 votes
1 answer
3k views

Decompress tar.gz file in Go

I want to extract tar.gz file and store the contents in the same directory. I got below method which does the job but I wanted to see if there is any way to improve ...
AndyP's user avatar
  • 229
5 votes
0 answers
2k views

C# Async FileInfo Extensions (Copy, Move, Delete)

Here is my effort to implement extensions for FileInfo object: ...
SeReGa's user avatar
  • 151
3 votes
4 answers
705 views

Generate HTML select tag and options using a text file having list of countries

The code below will generate an HTML select tag and options using a text file having list of countries. If the file doesn't exist or contains only empty / white space lines then generate an input box ...
user avatar
5 votes
1 answer
274 views

Optimized way to save list of files

I would like to optimize the way that I save files. Each second I save lots of strings in different files. What I want to do is bunch up these IO tasks so they happen in bursts, instead of spread out ...
Elikill58's user avatar
  • 148
4 votes
1 answer
277 views

Iterate through non-empty words from text files

Given a file or directory, create an iterator that returns the non-empty words from the file or from all files recursively in the directory. Only process ".txt" files. Words are sequence of ...
Abhijit Sarkar's user avatar
6 votes
3 answers
3k views

Reading 100,000 data files in Python

I need to manipulate data found in multiple data files (~100,000 files). One single data file has ~60,000 rows and looks something like this: ...
Alessandro Perego's user avatar
1 vote
2 answers
179 views

File reader and writer

I was told that the following code of mine was poorly written. How bad is it? Do you have any recommendations? ...
d8Alexander's user avatar
7 votes
2 answers
450 views

Word wrap with file input & ouput

As this is a very basic word wrap program, it has at least the following 3 limitations :- The file should have a terminating newline. The column number at which the lines are to be wrapped must be ...
Kushagr Jaiswal's user avatar
2 votes
1 answer
245 views

C++ simple type serialization for streaming primitive- / pod types over a web socket (e.g. asio)

I am experimenting with asio web sockets and tried to write a simple serializer / deserializer. I am also thinking about an approach on how to serialize some type information alongside the actual data....
Symlink's user avatar
  • 143
0 votes
1 answer
371 views

how to make inputs work well with special characters using the locale.h library? [closed]

for some reason the function setlocale(LC_ALL, "English") doesn't work when using an input function,(getchar, scanf, fgets,..), to get a special character, (Ç, ã, õ, é,...). ...
Eduardo Nunes's user avatar
7 votes
3 answers
775 views

Input validation

I am learning C from C Primer Plus, and am still a beginner. I have been introduced to only two functions for input, scanf() and ...
Kushagr Jaiswal's user avatar
3 votes
3 answers
807 views

Efficiently read a file into a (C) string using POSIX APIs

Exactly what the title says, this is a C++ class that attempts to read a file into a null-terminated string as efficiently as possible, using POSIX APIs. Obviously this is not intended to be portable ...
Ray Hamel's user avatar
  • 258
3 votes
2 answers
5k views

Filtering FASTQ file based on read names from other file (how to increase performance) Python

I have some code here that basically takes in a list of IDs (sequencing read names) using STDIN, and then filters fin (a gzipped FASTQ file) to just those reads ...
Set's user avatar
  • 372
0 votes
2 answers
107 views

Getline function

The following is my attempt at writing a getline() function that makes it a bit easier to work with. I suppose an easier way would be to use ...
David542's user avatar
  • 409
4 votes
4 answers
2k views

Limit fgets input to up to a certain number of characters

This question is an extension of this other question from Stackoverflow. The objective is to limit the input of characters read by fgets to up to a certain number of characters. And in the following ...
isrnick's user avatar
  • 141
0 votes
1 answer
579 views

Import XML files to MongoDb with Nodejs

Here is my code which will read XML files and import the data to MongoDb. Do you have any comments on my code? ...
Steve Ngai's user avatar
1 vote
1 answer
1k views

Read and sort 100 numbers from a text file

The program itself reads 100 values from a text file named input.txt. Then sorts those values in ascending order and writes the values to a new file called ...
HunterShaw's user avatar

1
2 3 4 5
10