c types problem
Svante Lindahl
zap at duvan.UUCP
Tue Jan 14 15:48:29 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 buy yourself a C-book!\n");
(void) fclose(fp);
}
% cc foo.c
% a.out
Go buy yourself a C-book!
More information about the Comp.lang.c
mailing list