jeffr@bcs800.UUCP (Jeff Riegel) (10/13/90)
/* @(#)help.c 1.0 */ /* ** why dosn't this work ??? */ #include <stdio.h> #include <direct.h> main(argc,argv) int argc char *argv[]; { int fd; struct fildes fdbuf; if (fd = open(argv[1],1) < 0) { printf("Could not open %s \n",argv[1]); exit(1); } _gs_gfd(fd,&fdbuf,sizeof(struct fildes)); printf("The file size is %ld \n",fdbuf.fd_fsize); close(fd); } When I run this I do not get the file size any suggestions ? -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Jeff Riegel | uucp: ...!gatech!emory!bcs800!jeffr Technical Support | delphi: j2 tel: +800 444 3070 | A process is a terrible thing to waste!
kirkenda@eecs.cs.pdx.edu (Steve Kirkendall) (10/13/90)
In article <1068@bcs800.UUCP> jeffr@bcs800.UUCP (Jeff Riegel) writes: > > if (fd = open(argv[1],1) < 0) { Your problem comes from the fact that the "<" operator has a higher precedence than the "=" operator, so that this line is parsed like this: if (fd = (open(argv[1],1) < 0)) { Which isn't right. If it opens the file successfully, then the fd will be set to "false", or 0. To have it parsed the way you want, try it this way instead: if ((fd = open(argv[1],1)) < 0) { ------------------------------------------------------------------------------- Steve Kirkendall kirkenda@cs.pdx.edu Grad student at Portland State U.
mithelen@vpnet.chi.il.us (Paul Jerkatis) (10/14/90)
>Item: 215 by jeffr at bcs800.UUCP >Author: [Jeff Riegel] Try: _gs_gfd(fd,&fdbuf,sizeof(fdbuf)); This works for me... -- Paul Jerkatis - Call the SandV BBS - 708-352-0948 (OS9/CoCo 3 support) UUCP: ...{clout|obdient|gargoyle!}vpnet!sandv!sysop DOMAIN: sandv!sysop@vpnet.chi.il.us Delphi: MITHELEN
mithelen@vpnet.chi.il.us (Paul Jerkatis) (10/14/90)
Oh.. Also... You need to put in: pflinit(); in the begining of main() before you print out floats or longs on the CoCo (Don't know about other OS9 machines)
Bill.Nobel@weyr.FIDONET.ORG (Bill Nobel) (11/08/90)
Jeff, you forgot to put a pflinit(); in the source code. You have to do this in the OS-9 C compiler to bring in the printf long integer functions. -Bill- -- Bill Nobel - via FidoNet node 1:140/22 UUCP: ...!herald!weyr!Bill.Nobel Domain: Bill.Nobel@weyr.FIDONET.ORG Standard Disclaimers Apply...