Skip to main content
edited body
Source Link
Chad G
  • 630
  • 3
  • 12

Well first of all you are trying to name the variable bytechar? which is already a keyword for the variable type of bytechar. But you can access it by the index of the array. Also not sure if you intended to make the array 8 bytes in length, and then only use 7, but thats what you had done in your example

//define it all at once
// charbyte byteArray[8] = {B10000,B01000,B00100,B00010,B00001,B11000,B11100};
//or by index
charbyte byteArray[8];
byteArray[0]=B10000;
byteArray[1]=B01000;
byteArray[2]=B00100;
byteArray[3]=B00010;
byteArray[4]=B00001;
byteArray[5]=B11000;
byteArray[6]=B11100;


//if you need to change one in the code elsewhere
byteArray[3]=B00110;
//or
byteArray[3]=6;
}

Well first of all you are trying to name the variable byte? which is already a keyword for the variable type of byte. But you can access it by the index of the array. Also not sure if you intended to make the array 8 bytes in length, and then only use 7, but thats what you had done in your example

//define it all at once
// char byteArray[8] = {B10000,B01000,B00100,B00010,B00001,B11000,B11100};
//or by index
char byteArray[8];
byteArray[0]=B10000;
byteArray[1]=B01000;
byteArray[2]=B00100;
byteArray[3]=B00010;
byteArray[4]=B00001;
byteArray[5]=B11000;
byteArray[6]=B11100;


//if you need to change one in the code elsewhere
byteArray[3]=B00110;
//or
byteArray[3]=6;
}

Well first of all you are trying to name the variable char? which is already a keyword for the variable type of char. But you can access it by the index of the array. Also not sure if you intended to make the array 8 bytes in length, and then only use 7, but thats what you had done in your example

//define it all at once
// byte byteArray[8] = {B10000,B01000,B00100,B00010,B00001,B11000,B11100};
//or by index
byte byteArray[8];
byteArray[0]=B10000;
byteArray[1]=B01000;
byteArray[2]=B00100;
byteArray[3]=B00010;
byteArray[4]=B00001;
byteArray[5]=B11000;
byteArray[6]=B11100;


//if you need to change one in the code elsewhere
byteArray[3]=B00110;
//or
byteArray[3]=6;
}
Source Link
Chad G
  • 630
  • 3
  • 12

Well first of all you are trying to name the variable byte? which is already a keyword for the variable type of byte. But you can access it by the index of the array. Also not sure if you intended to make the array 8 bytes in length, and then only use 7, but thats what you had done in your example

//define it all at once
// char byteArray[8] = {B10000,B01000,B00100,B00010,B00001,B11000,B11100};
//or by index
char byteArray[8];
byteArray[0]=B10000;
byteArray[1]=B01000;
byteArray[2]=B00100;
byteArray[3]=B00010;
byteArray[4]=B00001;
byteArray[5]=B11000;
byteArray[6]=B11100;


//if you need to change one in the code elsewhere
byteArray[3]=B00110;
//or
byteArray[3]=6;
}