Skip to main content

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
3 votes
3 answers
349 views

Append Buffer for Buffering Small write(2) Calls

The purpose of this is written in the comment below (it is meant to be used in a text editor): abuf.h: ...
Harith's user avatar
  • 9,687
2 votes
2 answers
149 views

A small header-only input output library

The library (inspired by stb libraries) attempts to provide some commonly used functions (reading a file into memory, determining the size of a file) that are missing from the C standard library ...
Harith's user avatar
  • 9,687
3 votes
1 answer
110 views

Read a line from a stream

Since the standard fgets() does not suffice for my use cases, as it doesn't automatically enlarge the target buffer if needed, and ...
Harith's user avatar
  • 9,687
6 votes
2 answers
647 views

C- Reading and Parsing textfile

I'm relatively new to C programming and currently tackling exercises on Advent of Code. The challenge I'm working on involves calculating the sum of integers within each group from a file and ...
Noob-in-C's user avatar
4 votes
2 answers
514 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
370 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
430 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
  • 451
1 vote
3 answers
164 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
2k 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
  • 351
6 votes
1 answer
647 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
358 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
2k 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
140 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,499
4 votes
2 answers
160 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
249 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
984 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
233 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
282 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
897 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
60 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
559 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
91 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
79 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
  • 309
1 vote
1 answer
3k 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
141 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
  • 309
1 vote
1 answer
189 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
180 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
  • 309
5 votes
0 answers
765 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
327 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
57 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
248 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
194 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
371 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
942 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
  • 239
6 votes
1 answer
3k views

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

Here is my effort to implement extensions for FileInfo object: ...
SeReGa's user avatar
  • 161
3 votes
4 answers
845 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
295 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
283 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
224 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
485 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
329 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
634 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
841 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
1k 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
  • 268
3 votes
2 answers
6k 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
127 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
  • 429

1
2 3 4 5
10