int main(){
  // modern unsigned int 8 bits
  uint8_t total = SUM + 10;
  uint16_t x = 20;

  // predefined macros
  printf("line: %d\n", __LINE__);
  printf("file: %s\n", __FILE__);
  printf("date: %s\n", __DATE__);
  printf("time: %s\n", __TIME__);

  // will print 1, like 1 byte :)
  printf("size of total variable is: %lu\n", sizeof(total));
  printf("size of x variable is: %lu\n", sizeof(x));
  printf("the total is: %d\n", total);

  printf ("Biggest of 1, 2, and 3 is %d\n", BIGGEST(1,2,3));
  return 0;
}
Esempio n. 2
0
static void	add(char *s1, char *s2)
{
  char *a, *b, *c;
  int la, lb, len;
  int i, j;
  int carry;
  int add;

  a = BIGGEST(s1, s2);
  b = SMALLEST(s1, s2);
  la = strlen(a);
  lb = strlen(b);
  len = la + 1;
  if (!(c = memset(malloc((len  + 1) * sizeof(char)), '0', len)))
    return ;
  c[len] = 0;
  for (i = la - 1, j = lb - 1, carry = 0; i >= IS_NEG(a); --i, --j)
    {
      if (IS_NEG(a) == IS_NEG(b))
	{
	  add = ALIGN(a, i) + ALIGN(b, j) + carry;
	  carry = add / 10;
	}
      else
	{
	  add = ALIGN(a, i) - ALIGN(b, j) - carry;
	  carry = (add < 0);
	  add = POS(add);
	}
      c[i + 1] = ASCII(POS(add % 10));
    }
  if (IS_NEG(a) && (a != SMALLEST(b, a)
		    || IS_NEG(b)))
    printf("-");
  print_nb(c);
  free(c);
}