c++.dos.16-bits - wrong code generated by tiny program of below thread
- Lars Hansen (13/35) Feb 15 2003 the following program compiled with sc "sourcefilename" produces a progr...
- Lars Hansen (1/4) Feb 15 2003 small correction: -mt causes filename truncation, not -mtd
- Lars Hansen (3/15) Feb 16 2003 the truncation is caused by -mt, or is a tiny program already 16-bit?
- Walter (6/21) Feb 17 2003 Don't open the file in append mode if you're going to fseek around in it...
- Lars Hansen (3/4) Feb 17 2003 ok, thanks for the info :-) that solves it; and it makes sense (another
the following program compiled with sc "sourcefilename" produces a program which does the following: appends b at end of file, places b at file offset 138 it should place b at file offset 71 and 138 (b is the char array) (also compiling with -o or -mtd produces this wrong code) Also two qs: 1. when compiled with -mt there's the optlink warning 23 "No Stack": so does the compiler not generate pushes or will they result in code loss? 2. when compiling with -mtd x.n filenames are shortened to x.3 filenames (x<8)resulting in the file rt.htm created by the program. Is there a workaround? dmc version 8.29n Lars#include <dos.h> #include <stdio.h> int main(void) { FILE *f; char b[4]; struct date d; getdate(&d); b[3]=d.da_day%10+48; d.da_day/=10; b[2]=d.da_day%10+48; b[1]=d.da_mon%10+48; d.da_mon/=10; b[0]=d.da_mon%10+48; f=fopen("rt.html","a"); fseek(f,71,SEEK_SET); fwrite(b,sizeof(char),4,f); fseek(f,138,SEEK_SET); fwrite(b,sizeof(char),4,f); fclose(f); return 0; }
Feb 15 2003
2. when compiling with -mtd x.n filenames are shortened to x.3 filenames (x<8)resulting in the file rt.htm created by the program. Is there a workaround?small correction: -mt causes filename truncation, not -mtd
Feb 15 2003
To write files in binary you need a "b" in the fopen call, as in fopen("rt.html","ab").It still doesn't work as expected.Third, 16 bit programs cannot handle file names other than 8.3. "rt.html" is not a valid 16 bit filename. Try "rt.htm".the truncation is caused by -mt, or is a tiny program already 16-bit? (thanks for the answers)"Lars Hansen" <lars.o.hansen gmx.de> wrote in message news:b2mhq8$2vp9$1 digitaldaemon.com...the following program compiled with sc "sourcefilename" produces a program which does the following: appends b at end of file, places b at file offset 138 it should place b at file offset 71 and 138 (b is the char array)
Feb 16 2003
Don't open the file in append mode if you're going to fseek around in it.. Open it in write mode ("wb"). Also, the 8.3 filename restriction is imposed by the 16 bit operating system. No way around it. A tiny program is 16 bit. "Lars Hansen" <lars.o.hansen gmx.de> wrote in message news:b2pcn7$2j4k$1 digitaldaemon.com...programTo write files in binary you need a "b" in the fopen call, as in fopen("rt.html","ab").It still doesn't work as expected.Third, 16 bit programs cannot handle file names other than 8.3. "rt.html" is not a valid 16 bit filename. Try "rt.htm".the truncation is caused by -mt, or is a tiny program already 16-bit? (thanks for the answers)"Lars Hansen" <lars.o.hansen gmx.de> wrote in message news:b2mhq8$2vp9$1 digitaldaemon.com...the following program compiled with sc "sourcefilename" produces awhich does the following: appends b at end of file, places b at file offset 138 it should place b at file offset 71 and 138 (b is the char array)
Feb 17 2003
Don't open the file in append mode if you're going to fseek around in it..ok, thanks for the info :-) that solves it; and it makes sense (another compiler perhaps isn't so strict and neads r+ etc. only for fread()s) Lars
Feb 17 2003