CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

int not 2 byte not volume +32767-3276

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
pic877
Guest







int not 2 byte not volume +32767-3276
PostPosted: Thu Apr 01, 2004 6:52 am     Reply with quote

Confused
i write program read value from atd an0-an5 of 16f877 by code this

int x;


x=readadc();

x cann't show value 1024 if value from readadc(); more 127 x is = -128


help me i can't understand int not 2 byte?
pic877
Guest







again
PostPosted: Thu Apr 01, 2004 6:58 am     Reply with quote

and i printf to rs232 by code

printf("%d",x);


it show -128 ---> 127 only

but i change code is
long x;

x=readatd();
printf("%ld",x);

it work! i think ccs is not ansi c langguage it new c style !!!! Laughing
SteveS



Joined: 27 Oct 2003
Posts: 126

View user's profile Send private message

PostPosted: Thu Apr 01, 2004 7:27 am     Reply with quote

ANSI C does not set the actual physical size of various data types (I think), so, in this case CCS is perfectly legal in saying an int is 8 bits. I have found (or actually learned from others on this list) that you will save yourself many headaches by using int8, int16 etc. It's a good reminder of the actual size of the variable you are creating, esp when you switch between embedded PIC and Windows programming as I do.

- SteveS
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group