Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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).

5
votes
3answers
79 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 ...
-3
votes
0answers
12 views

Trouble reading and printing content of my text file in Java Main Method [closed]

I have a text file shown below with different input types on a line that I am trying to read accordingly as shown below. I put the text file "Vehicle.txt" shown below directly in the src folder of my ...
0
votes
0answers
17 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
31 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
36 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 ...
2
votes
1answer
53 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
56 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: ...
3
votes
0answers
51 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
69 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
114 views

Simple stringifying using << operator

Background I wrote my_length class and some code. my_length can be stringified using ...
1
vote
3answers
63 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
111 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 ...
3
votes
0answers
41 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
49 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
126 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
114 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
122 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
92 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
355 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
88 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
107 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
117 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
88 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
81 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 ...
6
votes
5answers
910 views

Dynamic fgets in C

I wanted to make a function that will dynamically retrieve a line from a stream to a buffer. This function just needs to take in the char* and the stream to read ...
0
votes
2answers
72 views

Text processing program

I have written a Python program to loop through a list of X files, open each one, read line by line, and write (append) to an output file. Being that these files are several GB each, it is taking very ...
0
votes
1answer
51 views

Count lines of scala code (omitting empty lines) in a directory, traversing any subdirectories

I need to simply count lines of Scala code in a project, which includes some package(i.e. directory) hierarchy. I'm not sure about the performance of the code below. Can you help improve it, if ...
3
votes
1answer
60 views

Loading icons in two different sizes

I am loading 3000 individual icons at run time one of my controls uses large icons, the other uses small icons. This works however seems terribly inefficient. The only way I can get the icons to be ...
6
votes
2answers
658 views

Network Interface Object

I wrote a Network... thing (not really telnet); and it's pretty simple. No options, just straight I/O. It seems programs get so bloated easily. ...
4
votes
5answers
961 views

Implementing an alternative to scanf

Since almost all C functions designed to get data from stdin are bad / flawed: gets - the less said about this the better <...
5
votes
1answer
131 views

K&R Exercise 1-6 & 1-7: working with EOF

I'm working through K&R at the moment and I've found my first exercise that seems to be a good use for my first CodeReview post. Exercise 1-6 - Verify that the expression ...
1
vote
3answers
82 views

Given a series of characters from stdin, print their squared integer ASCII counterparts

This program in essence is extremely simple, however, it can be written in many different ways. I'm a beginner at C and I've written it in 5 different variations (mostly differing in the use of ...
1
vote
2answers
49 views

Method that reads an input file of a particular format and creates objects corresponding to the file

This is essentially a best practices question about reading a file and making sure it follows a specific format. My current implementation works, but it's a while ...
5
votes
2answers
118 views

Implementation of the `tac` command

As a C programming exercise, I implemented a minimal tac program that prints the input line by line starting from the last line. I'm looking for feedback on my ...
3
votes
1answer
33 views

Length-Based Frame Stream En-/Decoding in Go

I'm relatively new to Go, which is why I decided to post some code here. My goal is to en-/decode a TCP stream. The individual data packets length-based. The first two bytes are the unsigned size in ...
7
votes
2answers
973 views

Java, delete / update the line from the file by id

I am studying Java. Can you criticize my code and tell me what I need to do to make it better? I have code that reads a txt file(product base). It contains tabular data where lines are formatted as: ...
7
votes
2answers
2k views

Emulating C++ string input in C

I did the following exercise: Write a C program that does the equivalent of C++ string s; cin>>s;; that is, define an input operation that reads an ...
4
votes
4answers
142 views

Printing a file

The goal of this function is to print the contents of a file. Pretty much what the simple invocation of cat does. Since C is famously hard, I am looking forward to your comments. ...
3
votes
3answers
186 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
182 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
159 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
83 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
57 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
113 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
137 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 ...
1
vote
1answer
156 views
5
votes
2answers
988 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
113 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. ...
4
votes
0answers
57 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 ...