Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
sizeof human
//gcc 5.4.0 //Nwutobo Ugochukwu Samuel //sammycageagle@gmail.com //21/11/2018 //sizeof human #include <stdio.h> void sizeof_human(float n, char *buf){ char *units[] = {"B","kB","MB","GB"}; int len = sizeof(units)/sizeof(*units); int i; for (i = 0; i < len-1; i++){ if (n < 1024.0){ sprintf(buf, "%.1f %s", n, units[i]); return; } n /= 1024; } sprintf(buf, "%.1f %s", n, units[i]); } int main(void) { float i = 5000000000; char buf[256]; sizeof_human(i, buf); printf("%s", buf); return 0; }
run
|
edit
|
history
|
help
0
Spring 2017 Lab 4 v0.5
Memory leak
Project 3 Part 1 v1.6
Simple interest
AVANCE PREGUNTA 3 FICHEROS
TopLeftTriangle.c
sum of min and max
test1.c
Arrays
Welcome1