Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::clog,std::wclog

      From cppreference.com
      <cpp‎ |io
       
       
       
       
      Defined in header<iostream>
      externstd::ostream clog;
      (1)
      externstd::wostream wclog;
      (2)

      The global objectsstd::clog andstd::wclog control output to a stream buffer of implementation-defined type (derived fromstd::streambuf), associated with the standard C output streamstderr, but, unlikestd::cerr/std::wcerr, these streams are not automatically flushed and cout is not automatically tie()'d with these streams.

      These objects are guaranteed to be initialized during or before the first time an object of typestd::ios_base::Init is constructed and are available for use in the constructors and destructors of static objects withordered initialization (as long as<iostream> is included before the object is defined).

      Unlesssync_with_stdio(false) has been issued, it is safe to concurrently access these objects from multiple threads for both formatted and unformatted output.

      [edit]Notes

      The “c” in the name refers to “character” (stroustrup.com FAQ);clog means “character log” andwclog means “wide character log”.

      [edit]Example

      Run this code
      #include <iostream> struct Foo{int n;    Foo(){        std::clog<<"constructor\n";}    ~Foo(){        std::clog<<"destructor\n";}}; Foo f;// static object int main(){    std::clog<<"main function\n";}

      Output:

      constructormain functiondestructor

      [edit]See also

      initializes standard stream objects
      (public member class ofstd::ios_base)[edit]
      writes to the standard C error streamstderr, unbuffered
      (global object)[edit]
      writes to the standard C output streamstdout
      (global object)[edit]
      expression of typeFILE* associated with the input stream
      expression of typeFILE* associated with the output stream
      expression of typeFILE* associated with the error output stream
      (macro constant)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/io/clog&oldid=181467"

      [8]ページ先頭

      ©2009-2025 Movatter.jp