borland-c

System programming with C(Time interval)


I am new to system programming. I am trying to print time interval using the puts() function, but I am getting errors.

#include <stdio.h>
#include <DOS.h>
#include <BIOS.h>

unsigned long int far *time = (unsigned long int far*) 0x0040006C;

void main()
{
    unsigned long int tx;
    tx = (*time);
    tx = tx +18;
    puts("Before");
    while((*time) <= tx);
    puts("After");
}

Error Screenshot:

image

PS: I am using Borland C compiler, and DOSBox to run these programs.


Solution

  • In your screenshot you're trying to puts an int, which only takes char*.

    Try this instead of puts(tx)

    printf("%d", tx);