4 ms·
Rust: fn main() { println!("Hello, world!"); } C++: #include <iostream> int main() { std::cout << "Hello, world!"; }
by lambda 11y ago
Rust:
fn main() {
println!("Hello, world!");
}
C++:
#include <iostream>
int main() {
std::cout << "Hello, world!";
}
- masklinn 11y agoThe Rust version adds a newline (hence println) while the C++ version doesn't. Either the Rust version should use `print!`, or the C++ version needs an `<< std::endl`
- claudius 11y agoAdding '\n' to the string is perfectly fine, no std::endl needed (\n translates to the system-specific newline and the stream is flushed on destruction anyways).