We’re rewarding the question askers & reputations are being recalculated! Read more.

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
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 ...
51
votes
2answers
68k views

Redirecting subprocesses' output (stdout and stderr) to the logging module

I'm working on a Python script and I was searching for a method to redirect stdout and stderr of a subprocess to the logging ...
39
votes
5answers
4k views

Easier user input in C++

A more proper version of this utility can be found at the following link here: Giveth me thy easier user input in C++ - follow up. I've always been a little bothered by the fact, that in order to get ...
25
votes
4answers
3k views

“ONCE”, “UPON”, “A”, “TIME”

I'm working on a small program to perform various tasks on text content, primarily at the word level. I wrote these methods as ways to help prepare the raw text file into something more malleable, ...
23
votes
3answers
3k views

Parsing log files of HearthStone: The log reading API

I'm still working on a parser that can parse log entries from a game called HearthStone, the overall idea is that it will read the log file live when the game is running, parses the log file and show ...
20
votes
3answers
1k views

“Welcome to Buzzway Subs!”

There were a few recent questions which had a challenge like this: The subway shop provides catering for meetings and other events. All sandwich platters are $40 each. Cookie platters are $20 ...
15
votes
2answers
971 views

“Who are you, and where do you live?” — a Q&A exercise

This is my first attempt at a programme. Is it good form? Does it follow best practice? Or am I completely off the mark? ...
15
votes
2answers
939 views

K&R 1-21 write an “entab” program

From K&R exercise 1-21, Write a program entab that replaces strings of blanks by the minimum number of tabs and blanks to achieve the same spacing. Use the same tab stops as for detab. When ...
15
votes
2answers
1k views

File reader/writer (text)

Following-up on this post, I wanted to be able to use my FileWriter with a syntax reminiscent of .net's using blocks, which ...
14
votes
1answer
103k views

Reading data from Excel sheet with ExcelDataReader

Objective: I want to import an Excel file, and read the rows of certain columns. For this, I use ExcelDataReader. I've implemented a low-level class called ...
13
votes
6answers
1k views

What's in your file?

Another more simple project from my CS1 class that I didn't upload while I was sick last week: Write a program that computes all of the following statistics for a file and outputs the statistics ...
13
votes
2answers
389 views

Python 3 decompression routine 10x slower than C# equivalent

I'm relatively new to Python 3, especially IO programming, writing a Blender add-on to import model data. The model data is available in a custom compression, and I originally wrote code in C# to ...
13
votes
2answers
13k views

Better option than “errno” for file IO error handling

I have the following method for opening a file: ...
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 ...
12
votes
6answers
4k views

while(user == gullible)

The goal for this project was to: Write a program that continues to asks the user to enter any number other than 5 until the user enters the number 5. Then tell the user "Hey! you weren't ...
12
votes
1answer
288 views

Easy Bit IO. Very simple interface works up to N == 64

After reading this question Easy bitset I/O. I wanted to see if there was a simpler way of doing it. This is how I would define a way of outputting ...
12
votes
1answer
1k views

fgets() Alternative

size_t readline_tostring(char * restrict dest, size_t size, FILE * restrict stream) fgets() is OK yet it has some short-...
11
votes
3answers
1k views

Validity of macro for printf() call in a corporate environment

I wrote this program: #include <stdio.h> #define printS for(i=0;s[i];i++){printf("%c",s[i]);} int i; char s[] = "Hello World!\n"; void main() { printS; } ...
11
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 ...
11
votes
2answers
2k views

Taking arbitrary length input in C

Instead of having to use something like char buf[100500] and hope that no possible user input could be longer than 100500 bytes, I decided to make the following ...
11
votes
7answers
22k views

Reading Large Files in Java getting really slow

I am trying to read a large file ~200 MB (~300 million lines of text). I am using a relatively standard way of reading like: ...
11
votes
4answers
535 views

File editing program

I have written a Java class to replace text in file. The file contains database configurations and is as follows: ...
11
votes
3answers
7k views

Empty Line delimiter, single line output

I'm used to only processing, at most, one line of a file at a time. This is my first time changing the delimiter, and the objective here is to take a file containing lines such as: ...
11
votes
2answers
660 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 ...
11
votes
1answer
1k views

Scanner in Scala

I wanted to implement Java's Scanner in Scala. The goal for this class is to: Implement a Scala collection interface (probably ...
11
votes
1answer
186 views

Recreation of cat in C

I have a school project to create a program that works the same as the Linux cat. The code works, but I just need find out where I can Improve it or handle errors. ...
11
votes
2answers
320 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) ...
11
votes
2answers
33k views

Merging multiple JSON files using Python

I have multiple (1000+) JSON files each of which contain a JSON array. I want to merge all these files into a single file. I came up with the following, which reads each of those files and creates a ...
10
votes
6answers
6k views

Cola Machine #1

I have been working on the code listed here. I am working on Problem #2, 0 stars. Here's what I have to do: Write a program that presents the user w/ a choice of your 5 favorite beverages (Coke, ...
10
votes
4answers
1k views

Accepting user input for tickets and tips

I've done tutorials as well as searches. I need assistance in simplifying this code. Please don't do it for me- instead inform me of what, where and why you are trying to simplify or write less code. ...
10
votes
3answers
11k views

Storing words from an input stream into a vector

I'm extremely new to C++ and am doing the exercises on the book Accelerated C++. Here is one of the exercises: 4-5. Write a function that reads words from an input stream and stores them in a ...
10
votes
2answers
4k views

How can I find out why this Rust program to echo lines from stdin is slow?

Given the following Rust program: ...
10
votes
3answers
4k views

Writing .ppm images to a file

I am struggling with commenting and variable naming. My teacher says my comments need to be more explanatory and explicit. He says my variable names are also sometimes confusing. I was just wondering ...
10
votes
2answers
999 views

A program that reads input until end-of-file and echoes it to the display

It echoes files or strings to output, never both at once. It does work (in both Linux and Windows), but I can NOT guarantee that it is bug free. It works much like echo, but it works with files as ...
10
votes
4answers
7k views

Trimming fgets(): strlen() or strtok()

After a successful fgets(buffer, ...), it is often desirable to trim a potential End-of-Line '\n'. Of the following 2 methods, ...
10
votes
2answers
6k views

Reading input from console in F# (as a sequence of lines)

Consuming input line-by-line until the end is often useful. In C# I would write the following loop: while ((line = Console.ReadLine()) != null) { // ... I ...
10
votes
5answers
361 views

Summing user input

A small project I recently started. The program must sum all the numbers the user input. You must first specify how many numbers there will be. Sumaster.c ...
10
votes
3answers
159 views

Saving player name throughout script-launches

I would like to use this in a program to save users' names even after they relaunch the script. I was just wondering if there were some ways I could clean up this code. Note: this currently was made ...
10
votes
1answer
404 views

cat program in Prolog

In order to learn Prolog, I have implemented the cat command in Prolog. I want to know if the code is idiomatic and what could be improved. File ...
10
votes
0answers
630 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 ...
9
votes
3answers
4k views

Workout tracker

Around June of last year, I made my very first GUI 'app.' Wish I knew of this amazing site then, I thought for posterity's sake it would be great to get it reviewed. It's a simple I/O window just to ...
9
votes
4answers
744 views

FileWriter supporting writing to multiple files

I got bored with opening and closing files whenever I need to write to one, so I wrote a FileWriter class that's used like this: ...
9
votes
2answers
2k views

Print-based debugging

...
9
votes
2answers
782 views

Reading binary files in XTF format

I have a few thousand binary files that have corresponding structs in them, followed by any number of bytes (this exact number of bytes is given in one of the fields in the structs). I read in data ...
9
votes
3answers
6k views

Handle Java Process outputs without extra-threads

Usually, people would create two extra-threads in order to read the standard output and error respectively. However, the following code would allow to handle a Process outputs without those threads (...
9
votes
0answers
377 views

Idiomatic way to implement `tail -f` in clojure

Disclaimer: This is just an educational task to learn how to program in clojure and switch brain to immutable state-way of developing (the provided snipped has some unused variables which I didn't ...
8
votes
4answers
11k views

Read from a file and pick a random line

I've been learning Java lately and had some great feedback from the previous threads (hangman and guess a number games). I was challenged by a user to try to get this code done, so I'm posting it here ...
8
votes
4answers
9k views

Creating a unique file name in C#

I find that I am often writing files where the names either: Need to be incremented (rather than overwriting a file that already exists in the directory with the same name) Need to be timestamped ...
8
votes
4answers
692 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: ...
8
votes
6answers
618 views

K&R 1-23 Remove all C comments

From K&R exercise 1-23, Write a program to remove all comments from a C program. Don't forget to handle quoted strings and character constants properly. C comments don't nest. My solution, ...