corz.org text viewer..
[currently viewing: /public/scripts/c/uptime/uptime-seconds.c - raw]
#include <stdio.h>
#include <windows.h>

/*
    uptime v0.1
    
    outputs uptime to stdout, in seconds.
    this program is designed for trivial usage, forum
    signatures and suchlike.
    
    ;o)

*/


void main(int argc, char *argv[]) {
    long sec; sec = 0;
    
    if (argc > 1) { // there are no arguments!
        printf("\n outputs the number of seconds since the peecee booted\n\n");
        printf(" usage: uptime\n\n");
        printf(" no additional arguments required!\n");
        printf(" v 0.1 (c) corz.org 2005 ->\n");
        return 1;
    }

    // get number of milliseconds PC has been up..
    sec = GetTickCount() / 1000; // and convert into seconds
    
    // finally, output uptime to stdout..
    printf("%d", sec);
}

Welcome to corz.org!

I'm always messing around with the back-end.. See a bug? Wait a minute and try again. Still see a bug? Mail Me!