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

Indexing array in for loop

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
raman00084@gmail.com



Joined: 28 Jul 2014
Posts: 34

View user's profile Send private message

Indexing array in for loop
PostPosted: Sat Feb 06, 2021 1:53 am     Reply with quote

My data is:

x[0]=input[0]
x[0]=input[1]
x[0]=input[2]

x[1]=input[3]
x[1]=input[4]
x[1]=input[5]

x[2]=input[6]
x[2]=input[7]
x[2]=input[8]

Now i am doing the above in for loop:
Code:

for(int8 i=0; i<3; i++)
{

x[i]=input[i     ]
x[i]=input[i     ]
x[i]=input[i     ]

}

How can i index the input[] in for loop ?
What formula can i use ?
Since i am new to programming kindly help.
raman00084@gmail.com



Joined: 28 Jul 2014
Posts: 34

View user's profile Send private message

PostPosted: Sat Feb 06, 2021 3:19 am     Reply with quote

my solution is
Code:

unsigned int8 a=0;
for (i=0;i<3;i++)
{
x[i]=input[0+a]
y[i]=input[1+a]
z[i]=input[2+a]

a=a+3;


}
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