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).
3
votes
1answer
103 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
26 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 ...
4
votes
1answer
81 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
55 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
162 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 ...
2
votes
1answer
82 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
122 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
37 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
108 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 ...
3
votes
3answers
68 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
60 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 ...
2
votes
1answer
41 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
92 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
118 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
66 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.
...
3
votes
1answer
53 views
Enabling stack overflow protection with Y/N prompt
This asks the user if they would like to enable stack overflow protection. If they enter yes (Y or y), then a Boolean ...
2
votes
1answer
50 views
Multi threaded console IO
For many console applications it is handy to be able to receive input and output at the same time from multiple threads.
This is supposed to allow receiving input commands from multiple threads, while ...
5
votes
2answers
39 views
Slicing Stack Exchange data dump XML files into small bites
I was posed with a challenge when trying to load XML files from Stack Exchange into a SQL Server database; some of these XML files are extremely large (largest one being a whopping 67 GB in a single ...
3
votes
1answer
109 views
Simple XOR file encryption
In http://stackoverflow.com/a/39299060, I wrote the following program.
...
2
votes
3answers
212 views
Printing out vector<string> char by char
I have learned a bit of C in university and I'm now learning C++ independently. I'm trying to print out std::vector<std::string> ...
5
votes
2answers
275 views
Binary file Handling - Add,modify and display records
I have written a basic binary file handling program and have used goto, so I want to know how to improve this program by replacing goto with another function
...
2
votes
0answers
42 views
Writing a file sequentially
I've written a procedure which allows serialized writing of a stream. I don't in any way consider this done, but this is the beginning of it. I know there are other implementations out there like this,...
6
votes
3answers
86 views
CSV concatenator
I have the following code (running in LINQPad) which takes tens of thousands of CSV files and concatenates them to create a single file.
Each CSV file has two lines: a header line and a data line. I ...
5
votes
1answer
62 views
Testing file IO errors in python
Below is a simple class with two methods: the first calls open() to read in a file. The second calls the first method and does error handling.
There is also a ...
7
votes
3answers
252 views
Searching files in a directory for a string
I have the following static class that enumerates directories in a folder, then searches each file in the folder (it seems to only work with text files even thought I don't explicitly specify that) ...
3
votes
1answer
48 views
File shredder in x86 NASM Assembly
This is a file shredder utility that runs on Linux. It writes random bytes over the file contents, repeating this 48 times and calling sys_fsync after each pass to ...
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 ...
3
votes
0answers
28 views
Get only intended input from user through the console
I finally worked out all of the bugs in this bit of code. I'm pretty proud of it and I wanted to give it to all of you so that you could have it if you wanted it for any console programs that you make....
3
votes
1answer
64 views
Input-reading library for Node.JS
Recently I have been busy with nodejs and I thought to create something like this Java input library, so I started with some rough code like below:
...
2
votes
2answers
88 views
Rust function to read the first line of a file, strip leading hashes and whitespace
I’m writing a Rust function for getting a title based on the first line of a file.
The files are written in Markdown, and the first line should be a heading that starts with one or more hashes, ...
5
votes
0answers
43 views
Positioning a file pointer with MPI I/O
This toy code uses MPI I/O to read from a binary file.
It goes through reading:
an ASCII header
the first 10 doubles from an array of 100 ...
3
votes
2answers
47 views
Optimized Int Reader
I am new in Golang, and decided to create a function that could cater to my needs of reading an integer from stdin. I need the function to be as efficient and fast ...
3
votes
1answer
46 views
Read file contents to string safely
I've just started to teach myself Rust. I've written the following code to read a text file and store the contents in a String. Is this the typical way of doing ...
1
vote
1answer
110 views
Sum over selected numpy.ndarray column and write to a file
I am trying to write the sum of selected NumPy array column and write to a file.
The following code snippet is working fine:
...
4
votes
2answers
102 views
Invoicing Program Python
This is my invoicing program I made for myself to keep track of purchases people made from me. (Yes I know eBay does this for me but I wanted to see what I could make.) Basically it can search the ...
5
votes
1answer
142 views
Printing fizzy lines
Challenge
Given a test case print out a FizzBuzz Series.
Specifications
The first argument is a path to a file.
Each line includes a test case.
Each test case is comprised of three spaced ...
8
votes
2answers
214 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 ...
2
votes
1answer
36 views
Updating certain values in text file
So I need to update some certain values within text file based on actual values there. Any advice on making it more effective or just readable is appreciated.
Example text file:
...
5
votes
1answer
138 views
Printing JUnit test results in file by changing and using the 'out' static variable of 'System' class
I'm building a framework for comparing files (in my own way) using JUnit. All test cases have been packaged in a JAR which is ran independently using a .bat file I ...
0
votes
0answers
57 views
Register a node-client code through an API call efficiently?
I've got a node_module that reads ArcValues for a user and updates the config of the node client at user's local (root). Like so:
...
1
vote
1answer
103 views
0
votes
0answers
30 views
Read a file into a list tail-first
This is some code which I created to read a file into a list tail first. In this case, I need to search for something in the file from the end first so this works out perfectly for what I need.
<...
6
votes
1answer
85 views
Counting newlines in a file
I've started to go through Node tutorials on nodeschool.io, and the second assignment was to write a program that will count the number of newlines in a file and print it out. My solution looks like ...
0
votes
0answers
369 views
Golang: reading and writing files in parallel
I am trying to read a big file line by line, inspect and cleanse each row and write to either of two output files depending on the outcome. I am using channels for this. I am still quite new to this ...
3
votes
2answers
69 views
Extracting the longest line from standard input
I'm reading the K&R book and I'm interested in a program which finds the longest line on the input. I've written the same code as in the book, but I wanted to do it myself. I tried to write my own ...
0
votes
1answer
83 views
Composing IO and Async in haskell
Whether based on MVar or TVar, async implementation are always based on operation on some underlying monad IO and STM.
Making Async a monad on its own, as in F# async computation builder, if done in ...
3
votes
2answers
89 views
Exercise 1-22 from K and R: line folding
I'm currently learning C with K&R, i'm right now in the exercise 1-22, but it's a little... hard to understand (at least for me). It says:
Write a program to "fold" long input lines into two or ...
1
vote
0answers
27 views
Practicing rogue-wave I/O
What I'm doing:
Searching in current directory for a set of files.
Filtering the set.
Searching through the filtered set of files for a specific line sequence.
Write to an output file that line along ...
7
votes
2answers
67 views
Higher performance reading shorts from binary file
I just got rejected at the tech interview of a job application. They gave me the following exercise for me to complete:
They gave me a binary file with 10 million pairs of 16-bit signed integers. ...
13
votes
2answers
249 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 ...