C++: Difference between revisions

494 bytes added ,  18 September 2019
no edit summary
No edit summary
No edit summary
Line 4: Line 4:


== Standard Library ==  
== Standard Library ==  
=== Reading and Writing ===
Reading and writing is done using <code>fstream</code>.<br>
If you don't need r/w, use <code>istream</code> for reading or <code>ostream</code> for writing.<br>
<syntaxhighlight lang="C++">
#include <iostream>
#include <fstream>
int main() {
  std::istream my_file("my_file.txt");
  std::string line;
  # Read line by line
  # You can also read using <<
  while (getline(my_file, line)) {
    std::cout << line << std::endl;
  }
  return 0;
}
</syntaxhighlight>
=== Sleep ===
=== Sleep ===
<syntaxhighlight lang="C++">
<syntaxhighlight lang="C++">