gpt4 book ai didi

c - 增加字符串的字符值

转载 作者:太空宇宙 更新时间:2023-11-04 02:58:55 26 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Why do I get a segmentation fault when writing to a string?

这是一个小函数,正在测试这样写的东西。在这里,当我尝试这样做时,我试图增加字符串文字的字符值,但我遇到了段错误。你能告诉我这里做错了什么吗

#include <stdio.h>
int input_string(char *str)
{
printf("%s\n", str);
printf("%c\n", *str);
printf("%c\n", (*str)++); // I get a segmentation fault here, cant i increment the value like this ?
}
void main()
{
char *str = "andrew";
input_string(str);
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com