为什么字符串没有得到更新并且最后不打印任何内容

Why the string is not getting updated and doesn't print anything in the end

代码:

#include <iostream>
using namespace std;

int main() {

string message, rMessage;
getline(cin,message);

for(int i=0;i<message.length();i++) {

if( (message[i]>='a' && message[i]<='z') ||
    (message[i]>='A' && message[i]<='Z') ||
    (message[i]>='0' && message[i]<='9') ) {

  rMessage[i] = message[i];
}
else {
    continue;
     }
 }
    cout<<"Removed: "<<rMessage;
} 

问题:

它在输出中显示空白字符串,字符串长度为 0。 此代码是否正确删除标点符号?我们必须进行哪些编辑才能解决问题?

What edit we must do resolve the problem?

改变

rMessage[i] = message[i];

rMessage += message[i];

原因在你问题的评论部分给出。