c_piscine__offshore_mains/c02/common.c

39 lines
691 B
C
Raw Normal View History

2023-11-23 18:26:57 +00:00
#include <string.h>
#include <stdio.h>
#define TEST_SOURCE "HeLlo world!\0It's a\tBEAUTIFUL\tday!"
#define TEST_SOURCE_LENGHT 35
#define TEST_DESTINATION "GooDBye\0and thanks \tfor\rall the fish!"
#define TEST_DESTINATION_LENGHT 38
#define FG_WHT "\x1B[37m"
#define FG_MAG "\x1B[35m"
#define COLOR_RESET "\x1B[0m"
void dump(char *data, int len)
{
int i = 0;
while (i < len)
{
if (data[i] >= ' ' && data[i] < 127)
printf(" %c ", data[i]);
else
printf(FG_MAG "\\%02u" COLOR_RESET, data[i]);
i++;
}
printf("\n");
}
int bufcmp(char *this, char *other, int len)
{
int i = 0;
while (i < len)
{
if (this[i] != other[i])
return (i + 1);
i++;
}
return (0);
}