TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Michael Ramsey
from: David Noon
date: 1995-01-15 15:50:04
subject: writing text file

On Tuesday, 01-10-1995  Michael Ramsey wrote to All about "writing
text file" as follows:

MR> I need to know how to write an ascii string with an eol to 
MR> an arbitrary disk file.  We are working on a project that 
MR> must have all output written to normal dos ascii file.
MR>  
MR>  exa: "Windows 95 will never be released"
MR>  
MR>  We want to write this in C code and have it written to a file.

Hi Michael,

You do this the same way as you would in DOS - fopen(), fprintf()
and/or fputs(), and finished off by fclose(). Straight out of
, just like any other platform's C library. For example:

 #include 
 int main(void)
 {
     FILE *Report_file;

     Report_file = fopen("D:\\REPORTS\\MYREPORT.PRN","w");
     if (Report_file)
     {
         fputs("Windows 95 will never be released.\n",
              Report_file);
         fclose(Report_file);
     }
     else
         fputs("Unable to open report file.\n",stderr);

     return 0;
 }

The main thing is to make sure your files follow the DOS 8.3 naming
standards, even if you are using HPFS. Although DOS programs running in
a VDM can access files on HPFS partitions, they cannot "see" files
whose names do not conform to the 8.3 naming standard used by FAT
partitions.

Regards

Dave

 * KWQ/2 1.2i * What would chairs look like if our knees bent the other way?

--- Maximus/2 2.02
* Origin: OS/2 Shareware BBS, Fairfax, VA: 703-385-4325 (1:109/347)
SEEN-BY: 12/2442 620/243 624/50 632/348 640/820 690/660 711/409 410 413 430
SEEN-BY: 711/807 808 809 934 942 949 712/353 515 713/888 800/1 7877/2809
@PATH: 109/347 2 7 3615/50 229/2 12/2442 711/409 808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.