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
sum of arrays
18BCE2182 ASSESS_3 Q2
print_odd_pointer.c
Assignment 8
Lab 9 v0.6
example of scanf and basic integer manipulation
Perfect number
Area & Perimeter of Circle
B_141125_Burbuja
Area of a rectangular prism