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
7
votes
1answer
56 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
37 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
3answers
646 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
60 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
2answers
58 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
104 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
46 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
24 views

F# and UDP server/client

I have a simple UDP client/server code looke like: ...
1
vote
1answer
50 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
54 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
105 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
43 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
52 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
87 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
46 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
75 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
198 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
106 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
83 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
85 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
38 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
102 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 ...
3
votes
1answer
59 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
63 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
446 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
172 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
121 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
21 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
64 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
47 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
66 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
75 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
72 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
72 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
115 views

Simple stringifying using << operator

Background I wrote my_length class and some code. my_length can be stringified using ...
1
vote
3answers
66 views

Portably get one character from standard input using standard library only

While translating an old Basic game to C, I found myself needing a function to get one character from the keyboard. You can't do this with common standard C library functions like ...
3
votes
1answer
117 views

Determining whether (x,y) points in the input constitute a function

I'm learning Haskell, and I've finally gotten around to coding up some Haskell. This code passed my tests. This code takes a line from standard in which tells it how many cases it's going to have (1 ...
4
votes
0answers
74 views

Perl PasteBin scraper

I'd like to optimize my code and get a better of understanding of how I can perform the task I am doing better. I've only used Perl threads about 3 or 4 times now. The purpose of my script / code ...
1
vote
1answer
70 views

K&R Exercise 1-22. Fold (break) lines at specified column

Intro I'm going through the K&R book (2nd edition, ANSI C ver.) and want to get the most from it: learn (outdated) C and practice problem-solving at the same time. I believe that the author's ...
5
votes
1answer
158 views

K&R Exercise 1-21. Write a program `entab` that replaces strings of blanks with tabs

Intro I'm going through the K&R book (2nd edition, ANSI C ver.) and want to get the most from it: learn (outdated) C and practice problem-solving at the same time. I believe that the author's ...
6
votes
2answers
182 views

Minimalistic, self-contained class for reading a sectionless INI file

When sections are ignored and no writing capability is needed, an INI reader becomes quite simple to implement. Here is my attempt at reading a sectionless INI file without any non-...
5
votes
1answer
173 views

K&R Exercise 1-18. Remove trailing blanks and tabs from each line

Intro I'm going through the K&R book (2nd edition, ANSI C ver.) and want to get the most from it: learn (outdated) C and practice problem-solving at the same time. I believe that the author's ...
5
votes
3answers
143 views

SslStream-compatible ReadLine extension

This code is a Extension to just be able to read a line quickly and efficiently with support for SslStream. What i'm looking to achieve: Lower CPU usage by ...
3
votes
3answers
742 views

Simple puts() function in x64 assembly

I'm trying to write as simple I/O library in x64 using linux syscalls ...
2
votes
4answers
110 views

K&R Exercise 1-19. Reverse program input one line at a time

Intro I'm going through the K&R book (2nd edition, ANSI C ver.) and want to get the most from it: learn (outdated) C and practice problem-solving at the same time. For that reason, I'm trying to ...
1
vote
2answers
181 views

K&R Exercise 1-16. Find the longest line in the input and print its length and first N characters

I'm going through the K&R book (2nd edition, ANSI C ver.) and want to get the most from it. Note that, for the sake of exercise, I don't want to use techniques not introduced yet in the book and I'...
3
votes
0answers
173 views

K&R Exercise 1-13. Printing histogram of word lengths (vertical variant)

I'm going through the K&R book (2nd edition, ANSI C ver.) and want to get the most from it. How does the following solution look to you? Note that, for the sake of exercise, I don't want to use ...
3
votes
2answers
124 views

K&R Exercise 1-13. Printing histogram of word lengths (horizontal variant)

I'm going through the K&R book (2nd edition, ANSI C ver.) and want to get the most from it. How does the following solution look to you? Note that, for the sake of exercise, I don't want to use ...
3
votes
3answers
87 views

Calculate total, minimum, maximum and mean from a set of distances

I have only begun to learn C++ and am reading through the book, "Programming Principles and Practices Using C++". This bit of code is my attempt to complete exercise 3 at the end of chapter 4. The ...