Can we clear array?
if have data in sd card like:
1234a
5678a
9012a
and wanna like:
int number[4],sol[4]
while (myfile.available())
{
int data = myfile.read();
sol=data;
number=sol-'0';
i=i+1;
delay(1);
if(sol[4]=='a')
{
serial.println(((number[0]*1000)+(number[1]*100)+(number[2]*10)+number[3]),dec);
}
}
then clear sol[4]for record next number
can it?
if can how to?
1234a
5678a
9012a
and wanna like:
int number[4],sol[4]
while (myfile.available())
{
int data = myfile.read();
sol=data;
number=sol-'0';
i=i+1;
delay(1);
if(sol[4]=='a')
{
serial.println(((number[0]*1000)+(number[1]*100)+(number[2]*10)+number[3]),dec);
}
}
then clear sol[4]for record next number
can it?
if can how to?
code: [select]
sol=data;
that's error. sol needs index tell 1 of slots in array want put number in.
code: [select]
sol[3] = 0;
would set fourth element in zero.
also note:
there no sol[4]. created sol 4 elements, numbered 0 through 3. there no 4. error. still compile, comparing garbage memory outside of array.
code: [select]
if(sol[4]=='a')
Arduino Forum > Using Arduino > Programming Questions > Can we clear array?
arduino
Comments
Post a Comment