我有一个main程序:
int main() {
char *str = "hello";
printf("%s\n", str);
/* Shift first byte 1 to get "iello" */
/* Have tried
str[0] >>= 8; */
printf("%s\n", str);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
基本向上串的第一字节偏移的字节从去hello到iello或Hello以Iello
您无法修改字符串文字,将其更改为:
char str[] = "hello"; //not string literal
printf("%s\n", str);
str[0]++; //add 1 to the first element
printf("%s\n", str);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
270 次 |
| 最近记录: |