mirror of
https://github.com/nganhkhoa/CTF-All-In-One.git
synced 2025-06-23 11:45:04 +07:00
update integer overflow
This commit is contained in:
18
src/Others/3.3.2_width_overflow.c
Normal file
18
src/Others/3.3.2_width_overflow.c
Normal file
@ -0,0 +1,18 @@
|
||||
#include<stdio.h>
|
||||
void main() {
|
||||
int l;
|
||||
short s;
|
||||
char c;
|
||||
|
||||
l = 0xabcddcba;
|
||||
s = l;
|
||||
c = l;
|
||||
|
||||
printf("宽度溢出\n");
|
||||
printf("l = 0x%x (%d bits)\n", l, sizeof(l) * 8);
|
||||
printf("s = 0x%x (%d bits)\n", s, sizeof(s) * 8);
|
||||
printf("c = 0x%x (%d bits)\n", c, sizeof(c) * 8);
|
||||
|
||||
printf("整型提升\n");
|
||||
printf("s + c = 0x%x (%d bits)\n", s+c, sizeof(s+c) * 8);
|
||||
}
|
Reference in New Issue
Block a user