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

Array shift

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



Joined: 30 May 2009
Posts: 6

View user's profile Send private message

Array shift
PostPosted: Fri Oct 11, 2013 9:01 am     Reply with quote

Hi

I'm new user in ccs and i'm having a problem in shift 1 bit from my array.

I need to shift inside the for loop because i will make somethings yest
Code:

void f_switch()
{
   int i=0;

   int1 v_switch[16]={1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

   for (i=0;i<16;i++)
   {
      shift_right(v_switch,1,0)
or
      v_switch= v_switch >> 1

or  i dont know

   }

}


if there are any other way to declare my binary (16bits) array i will be glad too if anyone help me.

Thanks
newguy



Joined: 24 Jun 2004
Posts: 1903

View user's profile Send private message

PostPosted: Fri Oct 11, 2013 9:05 am     Reply with quote

Code:
void f_switch() {
   int i=0;

   int16 v_switch = 0x8000;

   for (i = 0; i < 16; i++) {
      // do whatever you need to here
      v_switch= v_switch >> 1; // shift your bit right here
   }

}
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