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

      1. <small id='VcYdU'></small><noframes id='VcYdU'>

        从‘const char*’到‘char’的无效转换

        invalid conversion from ‘const char*’ to ‘char’(从‘const char*’到‘char’的无效转换)

              <bdo id='1JVSa'></bdo><ul id='1JVSa'></ul>

            • <legend id='1JVSa'><style id='1JVSa'><dir id='1JVSa'><q id='1JVSa'></q></dir></style></legend>

                  <tfoot id='1JVSa'></tfoot>
                    <tbody id='1JVSa'></tbody>
                • <small id='1JVSa'></small><noframes id='1JVSa'>

                • <i id='1JVSa'><tr id='1JVSa'><dt id='1JVSa'><q id='1JVSa'><span id='1JVSa'><b id='1JVSa'><form id='1JVSa'><ins id='1JVSa'></ins><ul id='1JVSa'></ul><sub id='1JVSa'></sub></form><legend id='1JVSa'></legend><bdo id='1JVSa'><pre id='1JVSa'><center id='1JVSa'></center></pre></bdo></b><th id='1JVSa'></th></span></q></dt></tr></i><div id='1JVSa'><tfoot id='1JVSa'></tfoot><dl id='1JVSa'><fieldset id='1JVSa'></fieldset></dl></div>
                  本文介绍了从‘const char*’到‘char’的无效转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试使用以下代码行将字符串中的某个字符替换为空格:

                  I am trying to replace a certain character in a string with a space using the following code line:

                  str[i] = " ";
                  

                  如何在不出现问题标题错误的情况下实现这一点?

                  How can realize this without getting the error in the title of the question?

                  推荐答案

                  使用单引号

                  str[ i ] = ' ';
                  

                  在 C++ 中,标记 "" 是一个字符串文字,它表示一个包含两个字符的数组:字符集中一个空格的值(例如,ascii 中的值 32)和一个零.另一方面,标记 ' ' 代表一个带有空格值(通常为 32)的单个字符.请注意,在 C 中,标记 ' ' 表示一个带有空格值的整数.(在 C 中,sizeof ' ' == sizeof(int),而在 C++ 中,sizeof ' ' == sizeof(char) == 1.)

                  In C++, the token " " is a string literal which represents an array of two characters: the value of a space in the character set (eg, the value 32 in ascii) and a zero. On the other hand, the token ' ' represents a single character with the value of a space (usually 32). Note that in C, the token ' ' represents an integer with the value of a space. (In C, sizeof ' ' == sizeof(int), while in C++, sizeof ' ' == sizeof(char) == 1.)

                  这篇关于从‘const char*’到‘char’的无效转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Is Type(::x); valid?(是类型(::x);有效的?)
                  Difference between an inline function and static inline function(内联函数和静态内联函数的区别)
                  Compilation fails randomly: quot;cannot open program databasequot;(编译随机失败:“无法打开程序数据库)
                  Too many initializers error for a simple array in bcc32(bcc32 中的简单数组的初始值设定项过多错误)
                  No Member named stoi in namespace std(命名空间 std 中没有名为 stoi 的成员)
                  Error using a constexpr as a template parameter within the same class(在同一个类中使用 constexpr 作为模板参数时出错)

                      <tbody id='IbY1Q'></tbody>

                          <bdo id='IbY1Q'></bdo><ul id='IbY1Q'></ul>

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

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