> -----Original Message----- > From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf > Of beckiewynn@yahoo.co.uk > Sent: Saturday, April 01, 2006 4:51 PM > To: Microcontroller discussion list - Public. > Subject: Re: [PIC] C18 and "large" arrays > > > > I have an array of 299 chars, but I have a problem - after 255 the > > > array wraps round, i.e. if I do > > > a[257]=1 > > > then I will get a[1]=1 > > > Why is this happening? > > > I define the array like so: > > > > > > static byte a[299]; > > > > > > thanks, > > > Andy. > > What size is your index variable, sounds like its only > > 8 bits. > > No, it happens also with literals, i.e. if I do > a[257]=1 and actually use '257' then I get a[1]=1 > > > > > Jim Caveat that I don't use this compiler: But can you cast the literal? Such as a[(unsigned int)257]? PIC C compilers are really C-like but similer approaches work with C compilers. I don't know if this complier supports things like U or L as part of a literal. I use 256L for example in some 16-bit compilers to force the literal to be 32 bits to get rid of warnings sometimes like when comparing a literal to a variable. Will 257U work for you in this case? ------------------------------------- Notice of Confidentiality ---------------------------------------------------------- This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify postmaster@vgt.net. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist