我想知道如何使用字符串的替换函数将字符串的一部分替换为初始化变量。我知道您可以使用替换功能,string.replace(0,5,"*****)但这不是我想要做的。假设我有string randString = "apple";. 我将如何使用替换函数将字符串替换为单词 apple 中的字母“e”而不是使用string.replace(0,1,"e");I want it to be like thisstring.replace(0,1,randString[4]);
编辑:我有一个由 0 和 1 组成的随机字符串,我想用这个randomStr.replace(0,1,bin[0][6]);Where替换字符串的一部分,这bin[0]只是我拥有的众多二进制数之一。bin[0][6]是二进制末尾最后一个数字的位置。例如 bin[0] = 1001011 并且 bin[0][6] 为 1。