invalid conversion from ‘const char*’ to ‘char’

前端 未结 2 1973
忘掉有多难
忘掉有多难 2020-11-27 08:06

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 wit

2条回答
  •  [愿得一人]
    2020-11-27 08:36

    Single char literals are obtained with single quotes:

    str[i] = ' ';
    

    A literal with double-quotes is a full string literal (a null-terminated array of char), but you're only replacing a single char.

提交回复
热议问题