CodeWalrus

Development => PC, Mac & Vintage Computers => Topic started by: gameblabla on October 06, 2017, 09:30:12 PM

Title: Useless c i wrote
Post by: gameblabla on October 06, 2017, 09:30:12 PM
Post here your crappy code that either useless or very poor in quality.
Here's one, that calculates the time that takes for that mom to gain 70000000 kilos in milliseconds.

#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <time.h>

int main(void)
{
    double yourmom = 0.0;
    double timetohold[2];
    double final_result = 0.0;
    struct timespec ts;
   
    timespec_get(&ts, TIME_UTC);
    timetohold[0] = ts.tv_nsec;
   
    while (yourmom < 70000000)
    {
    yourmom += 1.0;
    }

    timespec_get(&ts, TIME_UTC);
    timetohold[1] = ts.tv_nsec;
    final_result = timetohold[1] - timetohold[0];
    printf("Your mom gained 70000000 kilos in %f milliseconds\n", final_result / 1000000);
    return 0;
}