Skip to contentSkip to conversation

Why my simple program does not work in dosemu?

DISCUSSION Alejandro Bonet 1 participant 1 message Dec 2, 2006

lore
Share & tools
lore
#0 lore raw

Hello:

Here is my simple program:

/************************************************************/ /* Pruebas para ver porque ftell se comporta raro en dosemu */

#include <stdio.h>

void PruebaArchivo(char *fnom)

{   FILE *fich;char ch,buf[100];
    fich=fopen(fnom,"r+b");
    if (fich==NULL) { printf("Archivo %s no encontrado\n",fnom);return; }
    buf[0]=0;
    for (;;)
       { printf("%ld: %s\n",ftell(fich),buf);
         ch=getc(stdin);
         if (ch=='a') { fread(buf,1,10,fich);buf[11]=0; }
         else if (ch=='t') fseek(fich,ftell(fich)-1L,SEEK_SET);
         else if (ch=='x') break; }
    fclose(fich);
}

void main(int argc,char *argv[])

{   if (argc<2) printf("Sintaxis: pruftell file\n");
    PruebaArchivo(argv[1]);
}

/************************************************************/

I have compiled it over msdos via Borland Turbo C 2.0, and also in GNU/linux via gcc. In both systems the results are identical.

But if i run the msdos version (attached as pruftell.exe) in dosemu, the behavior is absurd...

Why?

It seems as ftell returns the file buffer reads instead function fread reads.

Thanks in advance

Alejandro Bonet
Babel Informatica SL
[email protected]