Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 31 lines (28 sloc) 0.835 kb
41d9115 Signed numbers, C examples.
Alan Gutierrez authored
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 int
5 write(const char * filename, void * data, int length)
6 {
7 FILE *out;
8 if (!(out = fopen(filename, "w"))) {
9 printf("ERROR writing %s.", filename);
10 exit(1);
11 }
12 fwrite(data, length, 1, out);
13 fclose(out);
14 return 0;
15 }
16
17 int
18 main()
19 {
20 char n8[] = { 127, 1, 0, -1, -2, -128 };
21 unsigned char un8[] = { 255, 1, 0 };
22 double n64d[] = { -9.1819281981e3, -10, -0.11, 0, 0.11, 10 };
23 unsigned short int u16[] = { 65535, 65534, 1, 0 };
24 short int n16[] = { 32767, 128, 1, 0, -1, -129, -32768 };
25 write("vows/examples/n8", &un8, sizeof(un8));
26 write("vows/examples/-n8", &n8, sizeof(n8));
27 write("vows/examples/u16", &u16, sizeof(u16));
28 write("vows/examples/n16", &n16, sizeof(n16));
29 write("vows/examples/n64d", &n64d, sizeof(n64d));
30 }
Something went wrong with that request. Please try again.