Pure Programmer
Blue Matrix


Cluster Map

Stream I/O

L1

This page is under construction. Please come back later.

StreamIO1.rs
/******************************************************************************
 * This program simply copies an input stream to the console character by
 * character like the Unix 'cat' program.
 * 
 * Copyright © 2020 Richard Lesh.  All rights reserved.
 *****************************************************************************/

fn main() {
	let mut c:i32 = 0;
	while getcodepoint(c) {
		putcodepoint(c);
	}
}

Output
$ rustc StreamIO1.rs error[E0425]: cannot find function `getcodepoint` in this scope --> StreamIO1.rs:10:8 | 10 | while getcodepoint(c) { | ^^^^^^^^^^^^ not found in this scope error[E0425]: cannot find function `putcodepoint` in this scope --> StreamIO1.rs:11:3 | 11 | putcodepoint(c); | ^^^^^^^^^^^^ not found in this scope error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0425`. $ rustc StreamIO1.rs error[E0425]: cannot find function `getcodepoint` in this scope --> StreamIO1.rs:10:8 | 10 | while getcodepoint(c) { | ^^^^^^^^^^^^ not found in this scope error[E0425]: cannot find function `putcodepoint` in this scope --> StreamIO1.rs:11:3 | 11 | putcodepoint(c); | ^^^^^^^^^^^^ not found in this scope error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0425`.
StreamIO2.rs
/******************************************************************************
 * This program simply copies an input stream to the console line by line.
 * 
 * Copyright © 2020 Richard Lesh.  All rights reserved.
 *****************************************************************************/

fn main() {
	let mut line:&str = "";
	while getline(line) {
		println!("{}", line);
	}
}

Output
$ rustc StreamIO2.rs error[E0425]: cannot find function `getline` in this scope --> StreamIO2.rs:9:8 | 9 | while getline(line) { | ^^^^^^^ not found in this scope error: aborting due to previous error For more information about this error, try `rustc --explain E0425`. $ rustc StreamIO2.rs error[E0425]: cannot find function `getline` in this scope --> StreamIO2.rs:9:8 | 9 | while getline(line) { | ^^^^^^^ not found in this scope error: aborting due to previous error For more information about this error, try `rustc --explain E0425`.
StreamIO3.rs
/******************************************************************************
 * This program reads bytes from STDIN and prints them in decimal format.
 * 
 * Copyright © 2020 Richard Lesh.  All rights reserved.
 *****************************************************************************/

mod utils;

fn main() {
	binmode(cin);
	let mut c:u8 = 0;
	let mut count:isize = 0;
	while getbyte(c) {
		print!("{} ", c);
		count += 1;
		if count % 20 == 0 {
			println!("");
		}
	}
	if count % 20 != 0 {
		println!("");
	}
}

Output
$ rustc StreamIO3.rs error[E0425]: cannot find value `cin` in this scope --> StreamIO3.rs:10:10 | 10 | binmode(cin); | ^^^ not found in this scope error[E0425]: cannot find function `binmode` in this scope --> StreamIO3.rs:10:2 | 10 | binmode(cin); | ^^^^^^^ not found in this scope error[E0425]: cannot find function `getbyte` in this scope --> StreamIO3.rs:13:8 | 13 | while getbyte(c) { | ^^^^^^^ not found in this scope error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0425`. $ rustc StreamIO3.rs error[E0425]: cannot find value `cin` in this scope --> StreamIO3.rs:10:10 | 10 | binmode(cin); | ^^^ not found in this scope error[E0425]: cannot find function `binmode` in this scope --> StreamIO3.rs:10:2 | 10 | binmode(cin); | ^^^^^^^ not found in this scope error[E0425]: cannot find function `getbyte` in this scope --> StreamIO3.rs:13:8 | 13 | while getbyte(c) { | ^^^^^^^ not found in this scope error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0425`.

Questions

Projects

More ★'s indicate higher difficulty level.

References