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

1
vote
2answers
49 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
35 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 ...
-1
votes
0answers
22 views

Presenting a “wait for input”-type message before exiting program (on multiple OS's) [on hold]

Includes for std::string and cstrings: #include <string> #include <string.h> Preprocessor code testing for ...
3
votes
4answers
95 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 ...
6
votes
1answer
56 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
101 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
97 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
92 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
19 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
42 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
41 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
57 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
58 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
70 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
65 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
113 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
54 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
54 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
133 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
142 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
135 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
109 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
488 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
95 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
129 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
139 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
101 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
82 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
1k 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
74 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
58 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
70 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
659 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
1k 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
145 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
166 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
35 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
2k 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
143 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
274 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
197 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
209 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
58 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 ...