fmt_hello

C++ Fmt

shaozkshaozk cpp/fmt/fmt_hello.cpp · 20 行 · 更新于 2026-10-21

#include <string>
#include <vector>

#include <fmt/core.h>
#include <fmt/format.h>
#include <fmt/ranges.h>

int main() {
  // print string
  fmt::print("Hello, world!\n");
  fmt::println("Hello, world!");

  // print container
  std::vector<int> v{1, 2, 3};
  fmt::print("{}\n", v);

  // format a string
  std::string s = fmt::format("The answer is {}.", 42);

}

评论