Skip to content
เข้าสู่ระบบ

I/O - อ่านเขียนข้อมูล

std::io คือ module หลักสำหรับ Input/Output เช่น อ่านจาก stdin เขียนไป stdout!

std::io มี:

  • Traits: Read, Write, BufRead, Seek
  • Types: stdin, stdout, File, BufReader, Cursor
  • Error handling: io::Result<T>
use std::io::{self, Read, Write};
fn main() {
// ============================================
// io basics
// ============================================
// อ่านจาก stdin
// let mut input = String::new();
// io::stdin().read_line(&mut input).unwrap();
// เขียนไป stdout
println!("Hello, World!");
// io::Result<T> = Result<T, io::Error>
let result: io::Result<()> = Ok(());
println!("{:?}", result);
}

เข้าสู่ระบบเพื่อดูเนื้อหาเต็ม

ยืนยันตัวตนด้วยบัญชี Google เพื่อปลดล็อกบทความทั้งหมด