Path: utzoo!attcan!uunet!decwrl!elroy.jpl.nasa.gov!zardoz.cpd.com!dhw68k!arcturus!evil From: evil@arcturus.uucp (Wade Guthrie) Newsgroups: comp.lang.c Subject: Re: Beginning C question. Message-ID: <1990Jul25.213447.13750@arcturus.uucp> Date: 25 Jul 90 21:34:47 GMT Organization: Rockwell International Lines: 30 Wally Sze writes: > [...] My > compiler uses 16-bit ints, and I need to read some 32bit long ints > from disk. Try fread(). For example: #include ... FILE *file, *fopen(); long foo; int items = 1, actual_num; ... if( (file = fopen(...)) == NULL) /* some error handling here */ if((actual_num = fread(&foo, sizeof(foo), items, file)) != items) fprintf(stderr, "fread only read %d items", actual_num); In the scope of a prototype of fread (to allow for the proper cast of &foo) will read a single long into foo. -- Wade Guthrie (evil@arcturus.UUCP) | "He gasped in terror at what sounded Rockwell International; Anaheim, CA | like a man trying to gargle while My opinions, not my employer's. | fighting off a pack of wolves" | Hitchhiker's Guide