• <i id='Dg0Sm'><tr id='Dg0Sm'><dt id='Dg0Sm'><q id='Dg0Sm'><span id='Dg0Sm'><b id='Dg0Sm'><form id='Dg0Sm'><ins id='Dg0Sm'></ins><ul id='Dg0Sm'></ul><sub id='Dg0Sm'></sub></form><legend id='Dg0Sm'></legend><bdo id='Dg0Sm'><pre id='Dg0Sm'><center id='Dg0Sm'></center></pre></bdo></b><th id='Dg0Sm'></th></span></q></dt></tr></i><div id='Dg0Sm'><tfoot id='Dg0Sm'></tfoot><dl id='Dg0Sm'><fieldset id='Dg0Sm'></fieldset></dl></div>

        <small id='Dg0Sm'></small><noframes id='Dg0Sm'>

      1. <legend id='Dg0Sm'><style id='Dg0Sm'><dir id='Dg0Sm'><q id='Dg0Sm'></q></dir></style></legend>
          <bdo id='Dg0Sm'></bdo><ul id='Dg0Sm'></ul>
      2. <tfoot id='Dg0Sm'></tfoot>
      3. C++ 替代 perror()

        C++ alternative to perror()(C++ 替代 perror())

          <tbody id='oJv3s'></tbody>
          <bdo id='oJv3s'></bdo><ul id='oJv3s'></ul>

          <tfoot id='oJv3s'></tfoot>

        • <legend id='oJv3s'><style id='oJv3s'><dir id='oJv3s'><q id='oJv3s'></q></dir></style></legend>

          <i id='oJv3s'><tr id='oJv3s'><dt id='oJv3s'><q id='oJv3s'><span id='oJv3s'><b id='oJv3s'><form id='oJv3s'><ins id='oJv3s'></ins><ul id='oJv3s'></ul><sub id='oJv3s'></sub></form><legend id='oJv3s'></legend><bdo id='oJv3s'><pre id='oJv3s'><center id='oJv3s'></center></pre></bdo></b><th id='oJv3s'></th></span></q></dt></tr></i><div id='oJv3s'><tfoot id='oJv3s'></tfoot><dl id='oJv3s'><fieldset id='oJv3s'></fieldset></dl></div>

                  <small id='oJv3s'></small><noframes id='oJv3s'>

                • 本文介绍了C++ 替代 perror()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我知道我们可以使用

                  perror()
                  

                  在 C 中打印错误.我只是想知道是否有 C++ 替代方案,或者我是否必须在我的程序中包含这个(以及因此 stdio.h).我尽量避免使用 C 函数.

                  in C to print errors. I was just wondering if there is a C++ alternative to this, or whether I have to include this (and therefore stdio.h) in my program. I am trying to avoid as many C functions as possible.

                  推荐答案

                  你可以这样做:

                  std::cerr << strerror(errno) << std::endl;
                  

                  这最终仍然会调用 strerror,因此您实际上只是用一个 C 函数替换了另一个.OTOH,它确实让你通过流编写,而不是混合 C 和 C++ 输出,这通常是一件好事.至少 AFAIK,C++ 没有在库中添加任何东西来代替 strerror(除了生成 std::string,我不确定是什么无论如何,它会从 strerror 改变.

                  That still ends up calling strerror, so you're really just substituting one C function for another. OTOH, it does let you write via streams, instead of mixing C and C++ output, which is generally a good thing. At least AFAIK, C++ doesn't add anything to the library to act as a substitute for strerror (other than generating an std::string, I'm not sure what it would change from strerror anyway).

                  这篇关于C++ 替代 perror()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What is inside .lib file of Static library, Statically linked dynamic library and dynamically linked dynamic library?(静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么?)
                  How do I load a C DLL from the SXS in Python?(如何从 Python 中的 SXS 加载 C DLL?)
                  Can Cython code be compiled to a dll so C++ application can call it?(Cython 代码可以编译成 dll 以便 C++ 应用程序可以调用它吗?)
                  Delay Loading DLLs(延迟加载 DLL)
                  Throwing C++ exceptions across DLL boundaries(跨 DLL 边界抛出 C++ 异常)
                  Loading a dll from a dll?(从 dll 加载 dll?)

                    • <tfoot id='x4g3u'></tfoot>
                        <bdo id='x4g3u'></bdo><ul id='x4g3u'></ul>

                        <small id='x4g3u'></small><noframes id='x4g3u'>

                        <i id='x4g3u'><tr id='x4g3u'><dt id='x4g3u'><q id='x4g3u'><span id='x4g3u'><b id='x4g3u'><form id='x4g3u'><ins id='x4g3u'></ins><ul id='x4g3u'></ul><sub id='x4g3u'></sub></form><legend id='x4g3u'></legend><bdo id='x4g3u'><pre id='x4g3u'><center id='x4g3u'></center></pre></bdo></b><th id='x4g3u'></th></span></q></dt></tr></i><div id='x4g3u'><tfoot id='x4g3u'></tfoot><dl id='x4g3u'><fieldset id='x4g3u'></fieldset></dl></div>
                      • <legend id='x4g3u'><style id='x4g3u'><dir id='x4g3u'><q id='x4g3u'></q></dir></style></legend>

                              <tbody id='x4g3u'></tbody>