我对无符号数字(无符号短整数、整数整数和长整数)的了解,它仅包含正数,但以下简单程序成功地将负数分配给无符号整数:
1 /*
2 * =====================================================================================
3 *
4 * Filename: prog4.c
5 *
6 * =====================================================================================
7 */
8
9 #include <stdio.h>
10
11 int main(void){
12
13 int v1 =0, v2=0;
14 unsigned int sum;
15
16 v1 = 10;
17 v2 = 20;
18
19 sum = v1 - v2;
20
21 printf("The subtraction of %i from %i is %i \n" , v1, v2, sum);
22
23 return 0;
24 }
输出是:
The subtraction of 10 from 20 is -10