Home

Awesome

IceCream-C

Never use printf to debug again

Single header, implemented in C99 of IceCraem.

Based on rxi's log.c

use

import:

#include "icecream.h"

The exmple when there are no parameters

ic();

output

🍦 test/test.c:24 in main()

The example of printing string

char str_a[] = "hello";
char str_b[] = "world";

ic_str(str_a, str_b, "!");

output

🍦 str_a = "hello", str_b = "world", "!" = "!"

The example of printing int

int int_a = 32767;
int int_b = -32768;

ic_int(int_a, int_b, 999);

output

🍦 int_a = 32767, int_b = -32768, 999 = 999

The example of printing long

long long_a = 2141483647;
long long_b = -2147483648;

ic_long(long_a, long_b, 999999);

output

🍦 long_a = 2141483647, long_b = -2147483648, 999999 = 999999

The example of printing hex

int int_a = 32767;
int int_b = -32768;

ic_hex(int_a, int_b, 999);

output

🍦 int_a = 0x7fff, int_b = 0xffff8000, 999 = 0x3e7

The example of printing float

float float_a = 1.0;
float float_b = 2.0;

ic_float(float_a, float_b, 999.0);

output

🍦 float_a = 1.00, float_b = 2.00, 999.0 = 999.00

The example of printing double

double double_a = 1.0;
double double_b = 2.0;

ic_double(double_a, double_b, 999.0);

output

🍦 double_a = 1.0000, double_b = 2.0000, 999.0 = 999.0000

The example of printing pointer

char str_a[] = "hello";
char str_b[] = "world";
char *ptr_a = &str_a[0];
char *ptr_b = &str_b[0];

ic_ptr(ptr_a, ptr_b, "!");

output

🍦 ptr_a = 0x7ffee2bcf378, ptr_b = 0x7ffee2bcf380, "!" = 0x10d031e3e

License

This library is free software; you can redistribute it and/or modify it under the terms of the MIT license. See LICENSE for details.