Skip to content

Commit

Permalink
Create TestPrintln.cpp
Browse files Browse the repository at this point in the history
println & print
  • Loading branch information
w-boom committed Jul 31, 2024
1 parent 118981f commit 3700486
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions cpp/c++23/TestPrintln.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <print>

int main()
{
/*
1) Equivalent to std::println(stdout, fmt, std::forward<Args>(args)...).
2) Equivalent to std::print(stream, std::runtime_format(std::string(fmt.get()) + '\n'),
std::forward<Args>(args)...).
3) Equivalent to std::println(stdout).
4) Equivalent to std::print(stream, "\n").
*/
// Each call to std::println ends with new-line
std::println("Please"); // overload (1)
std::println("enter"); // (1)

std::print("pass");
std::print("word");

std::println(); // (3); valid since C++26; same effect as std::print("\n");

std::println("Please", "enter");

std::println("Hello, {}!", "World"); // 使用C++23特性
}

0 comments on commit 3700486

Please sign in to comment.