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
2
votes
3answers
1k views

Reading data from network stream

I have a function to request an update from the server. I provide the query and also indicate the expected length of the response. ...
3
votes
1answer
204 views

Exporting an object to a ZIP file

I have my own type of object, which implements Serializable. Here I have one called "extendedFormat" (not a terribly helpful name, yes, I know). I'm writing it out ...
4
votes
2answers
59 views

Header-only variadic console output and runtime input validation in C++ using templates

Template IO Module This is a single-file, header-only input validation with two variadic output functions. One output function simply inserts a new line char after every output and the other one ...
4
votes
1answer
72 views

Nisse Server: Part 3 Stream Layer

Getting close to a release of generic server. Nisse Server: Part 1 Helper Functions Nisse Server: Part 2 Socket Layer Here is the stream layer code. This basically provides a ...
1
vote
0answers
33 views

Download the contents of an HttpURLConnection while generating metadata

Working on a web crawler (again), except now I've had a lot more time to hone my skills. The largest bottleneck in my program, as is to be expected, is the actual downloading of the data, so I'd love ...
2
votes
1answer
74 views

Speed up Crawling Every File C:\ and hashing using Java 8

I am wondering if anyone can help me I am trying to read every file in every directory and create a hash of the file. The code works fine but is extremely slow, I wondering what I can do increase the ...
1
vote
1answer
114 views

Replace tabs with spaces

I wrote a program that replaces tabs with spaces. First, I defined a maximum length of an input string in the constant MAX_LIMIT. Next, I declared the procedure <...
3
votes
1answer
3k views

MIPS assembly program to read integer byte by byte

I try to learn assembly by writing small programs. This MIPS program is supposed to read an integer from the terminal and print it byte by byte in hexadecimal. I think it works but I didn't check ...
7
votes
1answer
2k views

Delete duplicate files

I have this function which looks through ALL files found in a directory (including sub folders) and deleted the duplicated file. ...
5
votes
3answers
2k views

Counting how many times each distinct word appears in an input

In chapter 3 of Koenig's Accelerated C++, he asks the reader to write a program that performs the task described in the title. At this point, he has only introduced the built-in types, io-types, and ...
3
votes
2answers
102 views

Efficient integer input / output (with a use case)

The task: A set of functions used to read/write integers from/to stdin/stdout as efficiently as possible. Rationale: printf/...
7
votes
2answers
134 views

Grouping Equivalent Files in Filesystem

The docstring in group_equivalent_files should be self-explanatory for what I'm trying to do. I'm specifically trying to group by equivalent files as opposed to just finding pairs of equivalent files. ...
2
votes
1answer
2k views

Golang Video stream Input/Output multiplexing

I wrote a camera client that will read a video stream and write to a player for playback. I have some basic keyboard controls ...
3
votes
2answers
292 views

C gets_s() implementation

I'm in a class that is using C, and my instructor has unfortunately used gets() in sample code. As this is obviously a heinous oversight, likely to cause undefined ...
6
votes
4answers
2k views

Writing and reading of character files

I've made the following Java-class just for getting some practice with the creation and reading of files. ...
2
votes
1answer
57 views

Load/save plain PPMs without error checking

I'm learning Lua. I decided to make a simple plain PPM decoder/encoder without error checks to familiarize myself with the language. I would appreciate any feedback on how could I make the following ...
11
votes
2answers
585 views

C library for standard input operations with data validation and error check

I have implemented a C library to perform basic input operations on built-in data types with various error checks of more complexity. Any improvements or suggestions are appreciated. GitHub ...
1
vote
1answer
523 views

F# binary reader

I've written a fairly simple script in F# which reads structured data from binary. I've avoided using the built-in .NET BinaryReader class because it's stateful in that it maintains its index in the ...
2
votes
2answers
62 views

Manage input values from file according to number of elements per line

I was given the a test file with the following kind of content, an arbitrary number of integer pairs divided by a newline and a final line with one integer: ...
5
votes
2answers
211 views

A python default dictionary which seamlessly saves to disk

I sometimes do experiments at work and separate the computation and the analysis so I can do the computation on a cluster and the analysis locally and sometimes in a Jupyter notebook. I wrote a class ...
-1
votes
3answers
82 views

Processing an InputStream and writing to an OuputStream, and ensuring that both streams get closed

Is it a bad thing to do multiple file closings in single finally block? Relevant excerpt: ...
1
vote
6answers
2k views

Reading strings into a vector, without using namespace std

I have been told that using namespace std is a bad practice (especially in header files). But wouldn't this make the program less readable? ...
2
votes
2answers
762 views

Cost calculator for room bookings, based on file or user input

The application I would like help with is a booking calculation tool that runs a few simple calculations in order to work out the cost of someone's stay. It currently contains only two java files, ...
6
votes
1answer
77 views

Line and column tracker for text files

A class that keeps track of lines and columns in a text file. I use it in a parser so that when an error occurs, I can print out the line and column at which it occured. Here's line col.hpp ...
3
votes
2answers
112 views

fprintf for heterogeneous struct

Is there a simple way to concatenate all of the fprintf(qFile, "%-1.1c", mod[cnt].name[x]); expressions into a small number of expressions? Appreciate any other ...
84
votes
5answers
15k views

Load fifty million integers as quickly as possible in Java

I am working my way through Project Euler. Many of the problems deal with prime number calculations: this is the type of code that can be extracted into a separate class and reused. While calculating ...
2
votes
0answers
37 views

Class which encapsulates related socket streams

I have a class which encapsulates stream related objects, and I have provided the method API for doing basic manipulation on the stream read/write/close, but is this a good approach? The only benefit ...
2
votes
2answers
142 views

Convert hours and minutes to total minutes

This is a simple exercise in C designed to work on IO. The purpose of the program is simple: convert a number of hours and minutes to a total number of minutes. ...
8
votes
2answers
162 views

entab program which replaces 4 spaces with a tab

I wrote an entab program which needs to replace every \$n\$ spaces with 1 tab. I picked \$n\$ to be 4, so every 4 spaces should be 1 tab. I have a feeling that my code is far too complicated than it ...
8
votes
1answer
1k views

AT&T Assembly - Basic loop & write

The code loops to display "Hello, World!" ten times. I would like someone to criticize it. I know that's far from being good assembly but I only started learning it a few days ago and I would like to ...
4
votes
0answers
844 views

subprocess with logging module: tee with StringIO

I've got a long-running process. Once it finishes I need the output. But the user should be informed while it's running. With the logging module I get timestamps ...
2
votes
0answers
455 views

Golang nanny process starting child process

The idea here is that my executable can be started normally (in which case it runs my business logic), or it can be wrapped in a nanny process (which starts a child process to run the business logic, ...
4
votes
1answer
127 views

Read/write to a file using AutoCloseable and objects for writing using Java

I am currently writing a small configuration API for myself, i want to use it to easily read/write to a file, however, i want to make sure it's efficient and get some other options into the field of ...
1
vote
1answer
2k views

Runs simple menu driven ATM program with various option in Java

RunMyAtm ...
3
votes
1answer
63 views

Querying a phone directory until end of input is reached

I need to create a phone directory with given inputs, then I need to query the dictionary for unknown number of given keys, if not found, print Not found. Link of Original HackerRank Problem here ...
3
votes
1answer
3k views

C++ Read File line by line

I wanted to have a good review on my code I wrote today to read files in C++ line by line. The file can look something like this: ...
5
votes
1answer
31 views

Short header file for safe CLI input handling in C

Proper input handling is a pain in the butt in C, so as part of a project of mine, this header is used to handle reoccurring command line input tasks such as input loops, reading lines and tokenizing ...
5
votes
1answer
109 views

Enforcing correct input/output of integers

The problem: Some types, like cstdint aliases or, at least purely theoretically, even std::size_t, may be (but don’t have to be)...
1
vote
1answer
385 views

Student Class in C++ using sstream for format

Based on my previous review, I'm posting another Hackerrank Class solution. Problem Statement We can store details related to a student in a class consisting of his age (int), first_name (...
13
votes
1answer
316 views

How many days to Go?

Here's my first serious attempt at writing Go code. This program counts the number of days until a certain date and displays that in the system tray. To do that, it first reads the target date from ...
3
votes
1answer
448 views

Text-based menu to manipulate a database text file

I am making a program that lets a user manipulate a database (a text file). In the code I am posting, I show only 2 of the menu choices, namely "createdb" and "deletedb", and a few functions I made ...
5
votes
1answer
1k views

Python library for awk-like file manipulation

I recently published a library for advanced awk-like file manipulation in Python 3. The code can be found here and here is the documentation. It is also available for download from pip (...
3
votes
0answers
199 views

Reading log file of subprocess

I run subprocesses with lot of output (compilation of Unity 3D projects). I use log parsers to find known issues. ...
8
votes
1answer
1k views

A box for comments

I made this as a practice application to learn React. It is simply a box where someone can enter their name and a comment and submit it, and display other comments. This animated GIF illustrates what ...
4
votes
3answers
1k views

2D Vector: Loading values from .txt file

I've written a program that runs through a matrix of numbers, ranging from 0 to 2, and stores the results in a 2D vector. I'm using the values in the 2D vector as the profile for a tile map for a ...
7
votes
1answer
183 views

Implementation of UNIX `tee` in Rust

I am currently reading Michael Kerrisk's book, The Linux Programming Interface. This is one of the exercises from the end of chapter 4 (I'm working in Rust, not C). A Rust implementation of the ...
3
votes
1answer
150 views

Construct: Rebuffered stream

This is part of the Construct library. Rebuffered is used to turn a seekless/tellless stream like from a socket or pipe into a seekable/tellable one like a BytesIO or a file. If ...
5
votes
3answers
187 views

Reverse input program in C99

I am writing simple program to reverse its input and output the reversed version. I came up with this code. So how can I improve it? Something tells me that ...
2
votes
2answers
2k views

Print consonant and vowels

My assignment is to to create two threads running functions (called vow and cons). The threads take turns printing the respective words of the phrase supplied from a text file. The main thread shouldn'...
2
votes
2answers
70 views

Spaces-to-tabs converter, updated version

I recently posted Spaces To Tabs Converter but it had lots of bugs, so I rewrote the code. I wanted to ask, is it good code? I didn't find any bugs. ...