gpt4 book ai didi

C++ 无法更改 Char 数组中的元素

转载 作者:行者123 更新时间:2023-11-30 05:11:39 25 4
gpt4 key购买 nike

<分区>

我是从 Java 开始接触 C 语言的新手。请解释一下为什么会这样:

text[0] = 'a';

不可能,我的程序崩溃了。

#include "caesarHead.h"
#include <limits.h>

int main(void) {

caesar("Hello this is a sample text", 12);

printf("\n\n");
}


void caesar(char text[], char offset) {
int i = 0;
text[0] = 'a';
char *p = text;

for (p; *p != '\0'; p++) {

printf("String: %c \n", text[i]);
printf("Ascii: %i \n", (int)text[i]);
i++;
}
}

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