ADVERTISEMENT
ADVERTISEMENT

Rust program to demonstrate the use of std::io::stdout().write() function

Rust Example: Write a program to demonstrate the use of std::io::stdout().write() function.
Submitted by Nidhi, on November 25, 2021

Problem Solution:

In this program, we will demonstrate the use of std::io::stdout().write() function. This function is used to write data on the standard output device and it returns total bytes written on the standard output device successfully.

Program/Source Code:

The source code to demonstrate the use of std::io::stdout().write() function is given below. The given program is compiled and executed on UBUNTU 18.04 successfully.

// Rust program to demonstrate the use of 
// std::io::stdout().write() function

use std::io::Write;

fn main() {
   let bytes = std::io::stdout().write("Hello World".as_bytes()).unwrap();
   
   println!("\nTotal byte written: {}",bytes);
}

Output:

Hello World
Total byte written: 11

Explanation:

In the main() function, we used std::io::stdout().write() function to write data on the standard output device that is "monitor". It returns the total number of bytes written successfully.

Rust Miscellaneous Programs »


ADVERTISEMENT
ADVERTISEMENT


Comments and Discussions!



ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.