Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!chinacat!uudell!mustang!jrh From: jrh@mustang.dell.com (James Howard) Newsgroups: comp.lang.c Subject: Re: Beginning C question. Message-ID: <7703@uudell.dell.com> Date: 24 Jul 90 04:09:14 GMT References: <10997@chaph.usc.edu> Sender: news@uudell.dell.com Reply-To: jrh@mustang.dell.com (James Howard) Organization: Dell Computer Corp. Lines: 36 In article <10997@chaph.usc.edu>, wsze@nunki.usc.edu (Wally "The Whale" Sze) writes: > I have a (beginning C) problem with a program I am working on. My > compiler uses 16-bit ints, and I need to read some 32bit long ints > from disk. > > (as a background, I wrote the same program for unix, and it worked > fine when I used getw(), but on my home compiler it doesn't.. getw() > returns only 16 bits). > > A way I can see to solve this is to read two ints from disk and > concantenate them. But how do you concantenate ints? Say I have > a = 0x20df and b = 0x3244, and want to get a long int 0x20df3244. > If anyone can help, or if you can think of a better way to do this, > please let me know by mail. Thank you. This works on my system: main() { short a=0x20df; short b=0x3244; int c; c = (a<<16) + b; printf("c = %x\n",c); exit(0); } I used "short" because they're 16 bits on this machine, and int's are 32. James Howard Dell Computer Corp. !'s:uunet!dell!mustang!jrh (512) 343-3480 9505 Arboretum Blvd @'s:jrh@mustang.dell.com Austin, TX 78759-7299