有没有可能在 C 中增加一个字符的 ASCII 值?假设我有以下代码
int main(){
char *a = "This is my test string";
/* *(a+12) += 21; This isnt going */
printf("%c = %c\n", *(a+12), *(a+12)+21);
printf("%s\n", a);
return 0;
}
例如,我想要的是将 e
字符增加 21,这将是 z
并使其永久存在于该数组中。因此,当我在数组上使用 printf
时,它会在该位置打印 z
而不是 e
。
我们将如何解决这个问题?
最佳答案
将 char *a = "This is my test string";
更改为 `char a[] = "This is my test string";
关于c - 替换C中字符串中字符的ASCII值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34169371/