C/C++?????????
???????????? ???????[ 2015/9/10 15:22:04 ] ????????????
????C/C++?г???????const????????????Щ??????????????С????????PI??????3.14159......
?????????????????????????????????????????????????????
???????磺
#include <stdio.h>
int main(int argc?? const char *argv[])
{
const int a = 0;
a = 2;
return 0;
}
??????????????
????const1.c: In function 'main':
????const1.c:5: error: assignment of read-only variable 'a'
???????????????????&???????a???????????????
#include <stdio.h>
int main(int argc?? const char *argv[])
{
const int a = 1;
printf("a = %d/n"?? a);
*((int *)&a) = 2;
printf("a = %d/n"?? a);
return 0;
}
??????????????asm???????Ч??????? x86????????????
#include <stdio.h>
int main(int argc?? const char *argv[])
{
const int a = 1;
unsigned int addr = (unsigned int)&a;
printf("a = %d/n"?? a);
asm ("movl $2?? %%eax;"
"movl %0?? %%ebx;"
"movl %%eax?? (%%ebx);"
:"=m"(addr)
:
:"%eax"?? "%ebx");
printf("a = %d/n"?? a);
return 0;
}
???????н????
????a = 1
????a = 2
????????????2?gcc??????????????????????????????????????????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11