C++如何删除字符串中的certan字符?

0 c++

你好,所以我基本上都是想做这样的事情.

PrintOpt("Hello | I | Am | Awesome");
Run Code Online (Sandbox Code Playgroud)

在我的PrintOpt代码中

void PrintOpt(char* Text){
     if(!strcmp(Text, " | ")){
           Text = "\n";
     }
     printf(Text);
}
Run Code Online (Sandbox Code Playgroud)

我希望它能像这样打印出来

Hello
I
Am
Awesome
(On a new line)
Run Code Online (Sandbox Code Playgroud)

但是,当我这样做时,它不打印任何东西.有谁知道为什么这不起作用?谢谢

Mar*_*ler 5

使用std::string替换方法