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).
4
votes
1answer
48 views
K&R 1-20 Solution
I'm currently reading the infamous K&R C book and trying to solve Exercise 1-20. My solution looks kind of too simple, but it works. I've searched the web for different solutions, but they all are ...
-1
votes
1answer
29 views
CodeEval “Read More” challenge [closed]
Here is the task, which is basically to truncate lines of input to 55 characters, or to 40 characters (also stripping a space if it happens to end in a space) and appending ...
1
vote
1answer
25 views
Using Pexpect for communication between multiple programs via I/O
I have a Python script that runs three compiled programs and makes them communicate via standard I/O. This is my first time using pexpect. My program runs very ...
5
votes
2answers
71 views
Prompting for a positive integer and validating user input in Java
I'm just starting out with Java, and trying to make a method to get a positive integer input from the console. My currently working implementation is this:
...
5
votes
1answer
37 views
Assembly Keyboard Input, data loss in registers
This is 8086/DOS assembly - .COM file format
I am working on a project for class, and it works as required by the rubric, though I am wondering if there is a slightly better way to implement a few ...
3
votes
1answer
40 views
Reading arbitrarily long lines from a file that is redirected as input
So I have a file with a list of dates that are to be redirected as input to stdin and what the program does is it searches for valid dates, appends them to the output file and then appends all the ...
4
votes
2answers
190 views
Multiprocess, multithreaded read write on a single file
I've got a job to create a library that would be able to support multithreaded and multi process read and write to a single file. On that single file we would store C# models in an array in JSON ...
4
votes
2answers
88 views
Reading file into structure
At the time I'm trying to read a quite big file into a C program for later user. The file size is in the range of 800 megabytes containing around 20 million lines of data of the following format:
...
3
votes
2answers
33 views
K&R C Exercise 1-14: Histogram of the frequency of types of characters
This is for K&R C Exercise 1-14: basically asking to create a program that prints a histogram of the frequency of types of characters. This is done with very basic C functions/knowledge as covered ...
1
vote
1answer
86 views
Reading input fast in Java for competitive programming
I have been solving problems on Timus Online Judge. In the beginning, I didn't worry much about I/O operations, so I just took some code from the internet and focused more on the logic. But after ...
3
votes
2answers
42 views
Constraining stdin in Python, v2.0
Rags, again.
This is the rewrite of Read stdin like a dictator.
From that post:
All too often I find myself wanting to allow only a certain list of characters to be written to stdin, and only ...
3
votes
1answer
39 views
Vigenère cipher as an IO filter
I implemented a Vigenere encoding and decoding class. Ideally, the program should be able to take any abritrary file, read into an array of byte, and decode it.
...
5
votes
1answer
55 views
Implementing cat function in Julia
I wanted to implement the cat function in Julia and I ran a few test cases but I am not sure if I am missing anything:
...
1
vote
0answers
38 views
Reading content of directory for each HTTP request
I have a piece of code written in node and I wanted to know if I am in the right direction. Basically I have a site where the homepage lists 6 vehicle cards. Every time the page is requested I do the ...
4
votes
1answer
33 views
Reading entire contents of file at a given java.no.file.Path into a String
What I'm wanting to do is create a String readFile(Path filePath, Charset encoding) method, that returns the entire contents of a given file.
I'm wanting the ...
8
votes
4answers
968 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
...
4
votes
1answer
35 views
Memory mapped classpath HttpServlet
I have a single page application where the resources sit on the classpath. Any request for a resource that doesn't exist should redirect to the index.html page. ...
8
votes
6answers
435 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 ...
15
votes
2answers
334 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. ...
16
votes
3answers
538 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 ...
2
votes
3answers
44 views
Path validation helper in a 'path input box'
I have a helper extension method that I use for path string validation. It looks as below. It's purpose is to work with network paths as well, so in case a network resource is not available, I do not ...
6
votes
3answers
205 views
Simple input/output practice
This code is just some exercise code printing questions and waiting for answers. It is working perfectly well as far as I can tell. I would like to know if this code could be considered acceptable or ...
4
votes
1answer
80 views
Method to read the number of lines in a web page
Needing a way to read the number of lines on a web page for the purpose of a progress bar the following method is created:
...
7
votes
2answers
108 views
Very basic Java file reader/writer
I started learning the Java language about 10 days ago, reading Introduction to Programming Using Java by David J. Eck. I've made it halfway through chapter six in about 9 days. I realized I was ...
4
votes
2answers
45 views
Compare Two Files
One of the K&R exercises is to write a small piece of software to compare two files and print the first line in which they differ.
Here is my attempt:
...
4
votes
1answer
47 views
Word Counter Project
I recently read K&R The C Programming Language and wanted to write a small program to count the occurrence of each word in the input (std-input - I piped a file with all shakespeare pieces in ...
3
votes
2answers
78 views
FIFO getch/ungetch Functions
I'm currently working myself through K&R and just read about implementing getch() and ungetch().
In K&R these ...
2
votes
1answer
85 views
4
votes
1answer
176 views
Read text file filled with numbers and tranfer to an array
This is my ProcessDataFileParallel.Java file. I'm taking numbers from a .txt file and putting it into an array in Java. While it works, I would like to improve the code and possibly change some ...
4
votes
1answer
99 views
Giveth me thy easier user input in C++ - follow up
I've decided to take some of the many suggestions for improvement on my previous question, Easier user input in C++, and actually get it to work as expected. This time around, a few things are ...
0
votes
1answer
75 views
Writing to a file in a multithreading application [closed]
This piece of code writes to a file and is used by multiple thread workers at the same time. From my observations, this is the slowest part in my whole application since threads have to wait for their ...
5
votes
3answers
402 views
Writing and reading code from a text file
Using file stream object, write a program to read an external text file ("myCourse.txt") which contains all the course name and numbers you are taking this semester, and to generate an analysis ...
3
votes
2answers
49 views
Getting a hash string for a very large file
After reading about large files and memory problems, I'm suspecting that my code below may be inefficient because it reads the entire files into memory before applying the hash algorithm. Is there a ...
4
votes
2answers
47 views
Speeding Up BufferedWriter
Are there any possible speed improvements I can make to the following method. It takes a JDBC ResultSet and breaks it into several CSV files:
...
1
vote
1answer
36 views
Searching and replacing text
Simple Playlist Modifier
This program is a search and replace program for text based files. The main goal of the program is to replace directory paths to music files.
The idea is to have the program ...
29
votes
5answers
2k 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 ...
0
votes
0answers
28 views
Downloading and reading data in go
I am trying to experiment with golang.
This code spins off two Go routines: one to download data and another to read from the body. Both go threads are synced by the data channel.
I have two ...
5
votes
1answer
144 views
Using a mutex to read from a file [closed]
I am new to C and I am trying to implement a mutex.
The idea of the program is:
main() will create three threads.
Each thread will read one character each from ...
4
votes
1answer
49 views
OutputStream class for use with subprocess.Popen
I've recently been writing an application which does a lot of work with the output of commands. To call the commands I've been using the subprocess module, and originally, was using ...
2
votes
3answers
134 views
Read file into list when class is instantiated in Python 2.7
I would like to read a file into a list when I create the class below. Once the list is ready, I would like to access it outside the class in order to process more code based on the list which now ...
3
votes
2answers
134 views
C - K&R getint() variation
I'm currently learning C with "The C Programming Language" by K&R. At the moment I'm at the chapter about pointers (since I come from Java, they are new to me). In the book is an example code for ...
5
votes
2answers
271 views
Print output one word per line - K&R Exercise 1-12
When writing this code I found myself getting more and more complex. When I got to the solution I trimmed the excess parts I'd thought I needed from before, but didn't actually need. The example of ...
21
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, ...
9
votes
1answer
115 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 ...
4
votes
2answers
80 views
8
votes
1answer
106 views
cat program in Go
In order to learn Go, I've implemented the cat program in Go. I want to know if the code is idiomatic and what could be improved.
...
10
votes
1answer
250 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 ...
3
votes
1answer
81 views
Pass the password back
This code simply receives a very basic 'password' (numbers, letters, nothing fancy). After you press enter, it will display it back. The only special key I'm handling is backspace (code ...
1
vote
1answer
671 views
Non-blocking Unix domain socket
I've developed quickly two kinds of socket use: the first with blocking mode and the second with non-blocking mode. The sockets are Unix domain sockets. My problem is that the kernel consume a huge ...
2
votes
1answer
64 views
Context managers that also deal with sys.stdin and sys.stdout
It's pretty typical for Linux command-line utilities that deal with files to accept either a file as input, or stdin. It's also pretty common for them to be able to ...