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
4
votes
1answer
68 views

C functions for fast IO for competitive programming

In some (perhaps not well-designed) competitive programming problems, the runtime and score is dependent on how fast your program can process input. Therefore I've written a small C99 library with ...
3
votes
1answer
77 views

Read file only once

I have a function that returns the contents of a file. Since reading files from disk is expensive, I'd like to avoid having to read the file again after the first read. I've come up with the ...
1
vote
1answer
44 views

Test a single-line file for punctuation and newline [closed]

I have written the following program to read from a file (entire input in single line) and check for: ASCII punctuation characters a final newline ...
0
votes
0answers
66 views

Efficient Timeout for a blocking operation without synchronization

I'm trying to create a timeout for a blocking operation, a InputStream.read() in the specific case, using a timeout thread without synchronization. This is needed ...
12
votes
5answers
3k views

Brute-Force algorithm in C++

I wrote a brute-force algorithm which shall find all possible combinations of ASCII-values that can sum up to a specific value (int hashval). The algorithm is ...
1
vote
1answer
69 views

Keep reading Command-line until you get the word END

I have to write a code which takes (integers) numbers from Command-line and keeps reading the terminal until it gets a word END So I wrote the following; I feel ...
3
votes
0answers
90 views

Python AsyncIO pipeline

I wrote a small snippet to implement asyncio Pipeline - object that connects together Layers, and lets them create and pass ...
5
votes
3answers
130 views

Proper way to find newest file in a directory

I wanted to ask if this is a better way to find a latest file in given directory. This is my current approach: ...
3
votes
0answers
36 views

Molecular .pdb File Reader in Rust

I am new to rust and wanted to get going with a medium-sized project to help learn. I've settled on creating some basic quantum mechanics code which starts with this bare-bones file reader. It takes a ...
9
votes
2answers
2k views

Print-based debugging

...
5
votes
2answers
70 views

Python image combiner reading writing

I am writing a simple script that will combine two images at a pixel level, selecting every other pixel from one image, and the other pixels from a second image. ...
5
votes
2answers
79 views

Display hexadecimal value stored at a register

I read a book about OS development and faced with a simple exercise: write a function that prints a hexadecimal value stored at a register. The program runs as a boot sector. I would really ...
2
votes
0answers
50 views

Implementation of SCPI for control of test instruments

I work with electronics test equipment. I like to be able to automate tests using their remote control interfaces. I have built a pattern, a few base classes, that I can apply to all devices that ...
11
votes
2answers
326 views

Self-inflicted killing utility

If you need to kill the same process that you're in (for testing purposes or whatever) this code will do it. A definitive, quick, unmerciful dead of the current Java program/app. Not a System.exit(0) ...
7
votes
1answer
97 views

Replacing spaces with tabs. Exercise 1-21 in “The C Programming Language”

I'm looking for feedback on the code I came up with for exercise 1-21 in "The C Programming Language" by K&R. Write a program entab that replaces strings of blanks with the minimum number of ...
4
votes
1answer
47 views

This program reads from serial port, Saves this to a text file, increments file name each time it is run

I want to condense it and get rid of any noob programming errors. The code works fine but I know it's not as elegant as it could be and I really want to improve. Your advice would be brilliant! I've ...
8
votes
4answers
700 views

Read string of any length in C

I've written code in C for reading a string of any length, and printing the string. It's one of my first C programs. I posted the program as part of a Stack Overflow question, and received a comment: ...
3
votes
3answers
63 views

Copy a FileInputStream to a file, either as text or as a string of bytes

I have written a small program that reads input from a text file and then writes this output to a text file. The method contains a switch which decides whether to output to the file as text or as a ...
6
votes
3answers
83 views

Function to prompt user for input

The following program calls a function, which prompts the user for input. The function then returns one of three enum constants; INPUT_SUCCESSFUL, ...
7
votes
2answers
110 views

K&R2 solution to exercise 1-18 (discarding trailing whitespace and empty lines)

Recently I have started learning C++ and I decided to learn C along the way to improve my understanding of how computers work. For C I am using "The C Programming Language Book" by Brian Kernighan and ...
0
votes
0answers
72 views

A FIFO ByteStream in python3

I want a FIFO queue for bytes conforming to python IOBase interface. I cannot find such a library available, nor could I produce one via trivial combinations of existiing libraries: ...
0
votes
0answers
45 views

F# and UDP server/client

I have a simple UDP client/server code looke like: ...
1
vote
1answer
58 views

Rust program, which reads, processes, and writes a file

I'm making a small program to benchmark Rust's performance compared to some other languages. The idea I came up with, was to take a file (with the numbers 1 to 10000000 written to it in separate lines)...
2
votes
1answer
64 views

Python Method for Text Input from Project Euler

Method Frequently input for problems is given as a 1D or 2D array in a text file. Have knocked out a method to do so, but believe something shorter, clearer and cheaper can be written: ...
4
votes
1answer
56 views

Reading from a stream but reserving N bytes at the end of stream

What I'd like to do is read data from a stream (like ifstream::read), but reserve N = 4 bytes from being returned. The last 4 bytes of the stream are not part of the data itself, but are metadata. In ...
2
votes
3answers
106 views

Reading words and counting their occurence in Java

I have very typical problem: Given big text file, containing text. The task is to calculate occurence of each word and print this info from most occured to less. Example input: ...
2
votes
1answer
49 views

Searching for matching shares

We're working on some code that involves validating certain UNC paths (specifically looking for things that appear to be subdirectories of other things), and we've gone back and forth on how to best ...
3
votes
1answer
55 views

Print file out 1 character at a time in the terminal - Python

This program opens a file and prints the text out to the terminal 1 character at a time and at a predetermined speed using time.sleep() Simple and maybe, if you ...
6
votes
1answer
91 views

Simple function to create Tokens from user input

I am new to programming in Rust and as an exercise I was making a simple Lottery checker program. It has a simple menu, the user enters a number for the corresponding option such as 'Add a line', '...
2
votes
1answer
63 views

Write input bytes to a file directly in Python3

I am using Python 3.6.1. This program simply allows a user to enter some bytes as a "string" and it writes those bytes to a file as actual bytes in the order provided. ...
1
vote
1answer
77 views

Go command-line tool to do some simple byte manipulation

I have some files containing 16-bit words in big-endian order, and a tool to process them that assumes little-endian order. I therefore need to swap the order of each pair of bytes in my files. This ...
6
votes
2answers
344 views

Implement a readN() from read7()

Exercise: Using a read7() method that returns 7 characters from a file, implement readN(n) which reads n characters. ...
1
vote
1answer
130 views

Calculate average from .txt file

I have made an exercise where I need to calculate the average per row of a .txt file. (see below) ...
1
vote
1answer
99 views

Program that deletes near duplicate directories and directories that have .ini like files

The program needs to only keep directories that have at least 1 .osu (.ini like) file with certain restrictions in them. It also needs to delete duplicate .osu files. But since duplicate files are ...
1
vote
2answers
88 views

Input class in Java

I'm a newcomer to Java (I primarily do C# ) and I have to say that they have made I/O handling much more difficult than it should have been. I am accustomed to the scenario where when I need keyboard ...
1
vote
0answers
55 views

Prompting the user to input a data value into an element in a linked list

I'm working through a practice problem that is having me build and modify a linked list over a series of steps. I am particularly interested in knowing if there's a more elegant way of prompting the ...
3
votes
4answers
109 views

Linux wc command in C

I'm working on my implementaion of the linux wc command. I finally have something that is working properly (with no options yet) but i think it needs a lot of "cleaning". I mean, i highly disrespect ...
4
votes
2answers
95 views

/proc/net/tcp results filter and converter

Being unable to easily read the output of /proc/net/tcp I made a small C# console app that modifies the output to be in decimal notation instead of the standard hexadecimal, show the corresponding ...
6
votes
1answer
66 views

Linux cat command in C

I wrote my own implementation of the linux cat command in C for my computer laboratory class. We were asked to replicate its functionality with no options passed as arguments or with just the -b, -n ...
10
votes
0answers
827 views

Asynchronous serial port communications class in C++

Please review my serial port class written in C++. It is completely asynchronous, ie event driven. My idea for later is to inherit from this a sync_serial, where timeouts can be specified and it ...
5
votes
3answers
305 views

My own getline function for reading strings from files

I am a newbie to C++ and I want to do some cool stuff with it. Here I have implemented my own getline function which reads from a file. so what do you think of this getline function? ...
5
votes
3answers
135 views

K&R C book, Exercise 1-21: Replace tabs with spaces

I'm new to C, just started reading K&R C book, and am working through exercises. This is my solution to 1-21, and as far as I tested it works. Anything that I'm doing wrong, or that it's not ...
0
votes
0answers
22 views

Go wrapper around io.Writer that tracks the number of bytes written

The code below implements ProgressWriter, a wrapper around io.Writer that can track the number of bytes written, and a function <...
1
vote
1answer
115 views

Simple unit test in C of input using freopen

Here is an initial attempt at unit test of user input in C. The thing that feels unusual is the use of freopen to send the test data to stdin. Are there better ways to implement this kind of test? <...
3
votes
2answers
55 views

Implementation of getdelim

Note: I wasn't trying to follow the POSIX getdelim signature exactly. I needed to add the consume argument for a project I'm ...
4
votes
1answer
67 views

Formatted reading

I thought it might be useful if reading could at least sort of mirror writing. For example, if I write some output like: ...
1
vote
2answers
140 views

Reading new data from a constantly updating file in Java

I have a log file which is constantly updated with new lines of data. I need to get new added data in java as soon as it's written. For now my solution is: ...
4
votes
0answers
84 views

One interface for multiple CRUD resources

I asked about an abstraction layer for accessing files (link) a couple of days ago (I decided to not call it a follow-up anymore as there are too many changes). I tried to incorporate many of the ...
1
vote
2answers
75 views

Read integers from coupled lines in a text file

I'm trying to read a text file formatted as in this example: 5 3 3 1 5 6 6 6 1 3 2 5 4 Where the lines are coupled, with the line above always being of length ...
3
votes
1answer
119 views

Simple stringifying using << operator

Background I wrote my_length class and some code. my_length can be stringified using ...