c types problem
Svante Lindahl
zap at duvan.UUCP
Tue Jan 14 15:48:21 AEST 1986
In article <1237 at gitpyr.UUCP> ken at gitpyr.UUCP (Ken Hall) writes:
>May I ask a stupid question? Would somebody post or send me a very short
>C program that open a file, write something to it, then closes it?
% cat > foo.c
#include <stdio.h>
main()
{
FILE *fopen(), *fp;
if ((fp = fopen("/dev/tty","w")) == NULL) {
(void) fprintf(stderr, "Can't open /dev/tty\n");
exit(1);
}
(void) fprintf(fp, "Go bye yourself a C-book!\n");
(void) fclose(fp);
}
% cc foo.c
% a.out
Go bye yourself a C-book!
--
Svante Lindahl, NADA, KTH (Dept of Numerical Analysis and Computer Science
at the Royal Institute of Technology)
UUCP: {seismo,mcvax,cernvax,diku,ircam,prlb2,tut,ukc,unido}!enea!ttds!zap
ARPA: enea!ttds!zap at seismo.ARPA
or Svante_Lindahl_NADA%QZCOM.MAILNET at MIT-MULTICS.ARPA
More information about the Comp.lang.c
mailing list