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
3
votes
3answers
384 views

InputStream Wrapper that closes the stream once reading is done

I faced some issues in a project with spring and hibernate where the stream given to Blob is not closed. ...
6
votes
2answers
202 views

Rot13 Unix Filter in C

I'm trying to brush up on some C basics (it's been ten years since I've programmed in C) and am working on a simple Rot13 program as a Unix filter. Any suggestions on how to improve it would be ...
0
votes
1answer
255 views

Strategy design pattern for writing to a file or to the console

I have this interface for all strategies: type PrintStrategy interface { Print() error } of two types: ...
2
votes
2answers
84 views

Populating a list with user input

I am trying to learn me some Haskell because I found it to be an interesting language. Right now, I am trying to implement a function in Haskell to get acquainted with the language. The function just ...
5
votes
1answer
61 views

Implementation of a buffer with an underlying FILE pointer

I am writing a library that will be used as input for any application the library is embedded, let's say, an interactive shell or to read from a FILE *. I need to ...
6
votes
3answers
114 views

SAT score reader program

This program takes 10 Math SAT scores and 10 Verbal Sat scores from the user, computes the standard deviation and averages, then displays them in a tabular format. After, it displays them to the user ...
4
votes
2answers
157 views

Entab.c - Program that replaces string of blanks by the min # of spaces & tabs to achieve identical output

This is Exercise 1-21 of K&R (2nd edition). I've seen someone else's post about it but it doesn't solve the problem the way my code does, and I wasn't sure whether I was allowed to post my code ...
2
votes
1answer
306 views

Reading a certain number of lines from a file

...
5
votes
2answers
1k views

Reading file and writing to output file with line numbers

I started learning java relatively recently as my first computer language independently and would like to see if my approach is efficient. An exercise in the book I am studying from tells me to read a ...
2
votes
1answer
28 views

Packing files in a directory to a single file in Java

My little program (called MrPackerUnpacker) takes a full path as an argument and creates a single file that can be unpacked to a folder later to reveal the packed files. Given the following 2 files ...
3
votes
1answer
138 views

Implementation of unix utility tail in C

I've written a simple implementation of tail as part of reading The C Programming Language by Kernighan & Ritchie. The question states to write tail, which prints the last n lines of its input. ...
5
votes
0answers
82 views

Convert a mix of latin 1 and UTF-8 to proper UTF-8

The following program takes an arbitrary byte sequence as input and outputs well-formed UTF-8. All UTF-8 sequences from the input are copied unmodified. All other bytes are assumed to be encoded in ...
4
votes
1answer
928 views

Custom ostream for a println-like function

I am writing a plugin in C++ that uses C API that gives me a single logging function with this signature: typedef void(*println_t)(const char* text); I want to ...
5
votes
3answers
1k views

Printing binary string in assembly

I'm writing a program to print binary string of a hardcoded word. Here is how it looks like currently: main.asm ...
1
vote
0answers
85 views

Echo in Prolog with single print (new version)

In order to learn a bit more of Prolog, I implemented the echo command for SWI-Prolog. I want a correct implementation, that is, it satisfies the following requirements: It makes only one I/O call ...
6
votes
1answer
128 views

K&R exercise 1-19, reverse line

I've just started to read K&R and currently, I'm dealing with problem 1-19: Write a function reverse(s) that reverses the character string ...
4
votes
1answer
1k views

Binary data utility class

I have recently been trying to get a solid grasp of how to work with binary data, both for networking and file storage, in C++. In java, there are many utility classes that made this easy. Since these ...
1
vote
1answer
675 views

Java method to load random paragraph from text file

Looking for some critique for this code. but ultimately I would like to be directed to resources/books that address my code writing weaknesses, in terms of style structure an convention : The task is ...
7
votes
2answers
315 views

Simple guessing game in Haskell

Here is a simple Guessing Game I implemented in Haskell ...
5
votes
2answers
138 views

C++ Range based stream

Hoping somebody has knowledge of the range based additions going into the standard. So they can point out all the things I need to add to make it compliant. IterableStream.h ...
4
votes
5answers
456 views

Fill a buffer up to its capacity and write() it out with minimal amount of work done

The below program is a write() based workload generator. I am creating a buffer that starts with a sequence number (starting at 0x11111111) before being filled to capacity with 0xDEADBEEF. This ...
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-...
3
votes
1answer
2k views

Multi-line input reader

I wrote two functions to read multi-line user input. ...
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. ...
5
votes
1answer
186 views

Optimizing 'yes' UNIX command in Java

the One of Unix core commands is yes which simply prints infinity number of letter y. I read a blog post (https://matthias-...
5
votes
2answers
302 views

Replace the content of a file by zero-bytes and keep the same filesize

Here is a little tool for Windows that replaces the content of a file with zero-bytes, keeping the same filesize. It works. The goal is to be sure that the old bytes-content of the file is no more ...
2
votes
2answers
447 views

Two methods to prompt the user to enter the width and length of a rectangle

I have two similar methods for setting dimensions of a rectangle. At first, I had them combined into one longer method that set width and length. I read about keeping code modular that performs one ...
3
votes
2answers
563 views

Print the number of vowels in C

I created this program to print the number of vowels of a given text in C; it is only a small exercise. I consider a vowel only the letters "aeiou", both in upper case and lower case. I provided a ...
1
vote
2answers
265 views

Read n lines, and count the lines that do not contain the string “CD”

I would like to know how to improve the execution speed of the code below. The context : n is an integer read from the stdin, and represents the number of cases. Each case is represented by a ...
0
votes
2answers
948 views

Number of Occurrences of a word in a text file or group of text files

The question given to me was as follows : WAP to take the input from the user a path and a word. If the path is a text file, search the word in the file and print the number of occurrences. If the ...
2
votes
2answers
309 views

Read lines from file, calling a consumer function for each line

I wrote a function for iterating over a large file with performance in mind. It takes in an InputStream and reads until it reaches the end of the file. Whenever it ...
3
votes
1answer
2k views

Validation of integer inputs from a BufferedReader

At my school, we are using the BufferedReader for keyboard input for our console apps and I don't want to have to write ways to validate input for every project so I am writing a class to validate ...
2
votes
2answers
134 views

Given an arbitrarily large file containing integers, return the largest N numbers, highest first

I've written a top_n program in Ruby, which does pretty much exactly what the title says, as part of a coding exercise. I'm trying to learn about how to sort ...
5
votes
2answers
321 views

Simple NBA Draft Order Generator

I wrote a simple program to create a random order for an NBA draft, prompt the user for input of draft picks, print the order of the draft and the results, and write the results to a text file. This ...
2
votes
1answer
443 views

C++ calculator program

For our first project in my C++ course this semester we had to do a simple calculator program. My background is mostly in Functional languages. What's the best way to do generic programming/...
4
votes
0answers
304 views

Error handling with C-string input using get() and getline()

I've just learned the basics of c-strings and how to read line oriented input. I noticed that fail bits are set for each function. However, not every problem sends a fail bit, so I thought this would ...
2
votes
2answers
162 views

Read file with URLs to connect to them, search for patterns and generate output in multi-threading env

I've been implementing a little application that will read a text file that holds URL addresses (one address per line). Example: ...
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
185 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
58 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
31 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
72 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
85 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
99 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
132 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 ...