scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

0033-memcmp.c (493B)


      1 #include <assert.h>
      2 #include <stdio.h>
      3 #include <string.h>
      4 
      5 /*
      6 output:
      7 testing
      8 done
      9 end:
     10 */
     11 
     12 int
     13 main(void)
     14 {
     15 	char buf[40] = {1, 2, 3, 4, 5};
     16 	signed char buf2[40] = {-127};
     17 
     18 	puts("testing");
     19 	assert(memcmp(buf, (char[]) {1, 2, 3, 4, 5}, 5) == 0);
     20 	assert(memcmp(buf, (char[]) {1, 1, 1, 1, 1}, 5) > 0);
     21 	assert(memcmp(buf, (char[]) {1, 3, 1, 1, 1}, 5) < 0);
     22 	assert(memcmp(buf, (char[]) {2, 3, 4, 5, 6}, 0) == 0);
     23 	assert(memcmp(buf2, (char[]) {-127}, 1) == 0);
     24 	puts("done");
     25 
     26 	return 0;
     27 }