C - 如何通过函数增加指向字符串的指针?

我想通过一个函数来执行下面的代码。

    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    
    int main(){
    char* string = "hello_World";
    string++;
    printf("%s\n", string);
    // ignore memory leak for sake of quiz
    return 0;
    }

输出:

ello_World

现在,我尝试将指针的引用传递给一个函数,然后递增它,而不是在 main 中递增指针。

    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    void myfunc(char** param){
    param++;
    }

    int main(){
    char* string = "hello_World";
    myfunc(&string);
    printf("%s\n", string);
    return 0;
    }

但输出是 hello_World

能否请您告诉我我编写的代码中发生了什么以及如何更改它以获得所需的结果?

最佳答案

您将指针递增到指针,您需要 (*param)++;

https://stackoverflow.com/questions/64354819/

相关文章:

python - Pandas 数据框拆分并获取列表的最后一个元素

arrays - 如何使用 Perl 剪切数组中字符串的第二列

ios - 禁用长按返回按钮(标注菜单)

python - 使用 Python 从 oddsportal.com 抓取数据

arrays - 为什么在初始化指针时必须将数组转换为 type[]?

android - 如何解决 android.content.res.Resources$NotFo

java - cf 推送失败 Java 版本不匹配

php - 如何使用 symfony 5 摆脱国际弃用消息

delphi - 如何在 delphi 7 中使用 setlocaltime?

c# - 如何在 ASP Core 的静态类中使用 "IWebHostEnvironment"