C appending char to char*

前端 未结 5 988
一个人的身影
一个人的身影 2021-01-18 06:15

So I\'m trying to append a char to a char*.

For example I have char *word = \" \"; I also have char ch = \'x\';

5条回答
  •  梦谈多话
    2021-01-18 06:25

    If you're passing in

    append("foo", 'X');
    

    it will crash, because foo is normally put in readonly storage. Even if it isn't it will overwrite something bad probably! In this case the compiler if it's kind should warn you of conversion from const char * to char * which would be a clue.

提交回复
热议问题