Hacker News new | ask | show | jobs
by lambda 3771 days ago
Rust:

  fn main() {
      println!("Hello, world!");
  }
C++:

  #include <iostream>
  
  int main() {
    std::cout << "Hello, world!";
  }
1 comments

The 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`
Adding '\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).