1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

paiza.ioでrust その5

Posted at

概要

paiza.ioでrustやってみた。
fileの読み書きやってみた。

サンプルコード

use std::fs;
use std::io::{Write, Read, BufWriter, BufReader, copy};


fn buffer_io() {
	{
		let b = "
		闇バイト
		行き着く先は
		生き地獄";
		let mut f = BufWriter::new(fs::File::create("test.txt").unwrap()); 
		f.write(b.as_bytes()).unwrap();
	}
	{
		let mut f = BufReader::new(fs::File::open("test.txt").unwrap()); 
		let mut buf = vec![];
		f.read_to_end(&mut buf).unwrap();
		println!("{}", std::str::from_utf8(&buf).unwrap());
	}
}
fn main() {
	buffer_io();
}


実行結果


		闇バイト
		行き着く先は
		生き地獄

成果物

以上

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?