Problem in opening COM1:

Stephen Clamage steve at taumet.com
Fri Feb 22 02:55:39 AEST 1991


panguyen at vela.acs.oakland.edu (panguyen) writes:

>#include <stdio.h>
>main()
>{
>  fopen( "COM1", "r+" );
>  fprintf( "CHN %d \r", 3 );
>} 
>This will cough back at me with the following errors,	  

>   Write fault error writing device COM1
>   Abort, Retry, Ignore ?

Apart from other help already posted, please note that fprintf()
requires a first parameter of type FILE*, usually the result of an
fopen() call.  So your example at minimum should have looked more
like this:

    FILE *com1 = fopen( "COM1", "r+" );
    if( ! com1 )
	... error: can't open COM1
    fprintf(com1, "CHN %d \r", 3 );

This is apart from any machine-specific problems there may be with COM1.
-- 

Steve Clamage, TauMetric Corp, steve at taumet.com



More information about the Comp.lang.c mailing list