Snippet #123092
on 2022/11/01 1:07:09 (UTC) by rotense as C
-
#include "main.h"
-
#include <stdio.h>
-
-
/**
-
* simple_print_buffer - prints buffer in hexa
-
* @buffer: the address of memory to print
-
* @size: the size of the memory to print
-
*
-
* Return: Nothing.
-
*/
-
void simple_print_buffer(char *buffer, unsigned int size)
-
{
-
unsigned int i;
-
-
i = 0;
-
while (i < size)
-
{
-
if (i % 10)
-
{
-
printf(" ");
-
}
-
if (!(i % 10) && i)
-
{
-
printf("\n");
-
}
-
printf("0x%02x", buffer[i]);
-
i++;
-
}
-
printf("\n");
-
}
-
-
/**
-
* main - check the code
-
*
-
* Return: Always 0.
-
*/
-
int main(void)
-
{
-
char buffer[98] = {0x00};
-
-
simple_print_buffer(buffer, 98);
-
_memset(buffer, 0x01, 95);
-
printf("-------------------------------------------------\n");
-
simple_print_buffer(buffer, 98);
-
return (0);
-
}
Recent Snippets
- #157071 by Anonymous (737 days ago)
- #156876 by Anonymous (737 days ago)
- #154030 by Anonymous (741 days ago)
- #140524 by Anonymous (760 days ago)
- #137907 by rotense (764 days ago)
- #131892 by Anonymous (771 days ago)