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

Calculate int and sent result to Array but it Error

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



Joined: 16 Jun 2010
Posts: 31

View user's profile Send private message

Calculate int and sent result to Array but it Error
PostPosted: Tue Jul 16, 2013 11:25 pm     Reply with quote

I calculate time like this
Code:

int next_time(int16 hr, int16 min, int pos){

lcd_gotoxy(1,2);
DS1307_ReadTime();

int16 minimVal;
int i=0,count = 0,check;
int16 hrk[],mnk[],all[];
int16 now_all;
int16 now_hr,now_min;
int16 a1,a2,a3;

now_hr = bcd2bin(RTC.hr);
now_min = bcd2bin(RTC.min);
   
hrk[pos] = hr;
mnk[pos] = min;
all[pos] =(hrk[pos]*60) ;

minimVal = (hrk[0]*60) + mnk[0];
now_all = (now_hr*60)+now_min;

printf("\r\n\n\n a=%ld, n=%ld",all[pos],hrk[pos]);

when I run this code and send value to function it show like this
Quote:

a=180, n=3
a=735, n=4

if n=4 it should be 240 but why it is 735.
when I comment //now_all = (now_hr*60)+now_min; it show correct result. How to calculate it ? Please help me.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Jul 17, 2013 1:24 am     Reply with quote

Which size do you expect for the [] arrays? Do you understand what happens for pos > 0?
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