From: stryyker AT my-deja DOT com Newsgroups: comp.os.msdos.djgpp Subject: Re: Char to Int Date: Tue, 10 Oct 2000 08:26:41 GMT Organization: Deja.com - Before you buy. Lines: 29 Message-ID: <8rujrt$jtr$1@nnrp1.deja.com> References: <8ru734$ab7$1 AT nnrp1 DOT deja DOT com> <8aviOQJFsqLNejHQEsWJk7JTrdYF AT 4ax DOT com> NNTP-Posting-Host: 203.173.253.150 X-Article-Creation-Date: Tue Oct 10 08:26:41 2000 GMT X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98) X-Http-Proxy: 1.0 CPROXY:8080, 1.0 x66.deja.com:80 (Squid/1.1.22) for client 203.173.253.150 X-MyDeja-Info: XMYDJUIDstryyker To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com In article <8aviOQJFsqLNejHQEsWJk7JTrdYF AT 4ax DOT com>, Jack Klein wrote: > On Tue, 10 Oct 2000 04:48:37 GMT, stryyker16 AT hotmail DOT com wrote in > comp.os.msdos.djgpp: > > > Currently I am reading a binary file data as Char type. How do I > > convert this to 8 bit int? How do I convert back? I am writing a tool > > to manipulate wav files. > > If you are reading binary data files make sure you open them in binary > mode, that is use "rb" instead of just "r". Also you are better off > reading them as unsigned chars, rather than plain chars. > > A char in C and C++ is just a small integer. In the case of DJGPP it > is an 8 bit integer already. You don't have to do anything to it to > convert it. > > Jack Klein > -- > Home: http://jackklein.home.att.net > I have the data in char x. How do I divide by 16 or something and make x reflect the result? I keep getting the original value or 0. Sent via Deja.com http://www.deja.com/ Before you buy.