A stupid question on construction of char out of chars

Guys, this is a continuation of the thread

Basically, I need to send a char array, ethernetStreamOut with size of 10. Thus the variable is this wwhich will hold a char array (aka char string).

Now, there are another set of variables, GPIO[0] till GPIO[10] which will hold 1 or 0 only.

my final product, ethernetStreamOut will become like this: <100010010>

Any code piece as I’m stuck in here… (I’m a newly converted from String to char and struggling on how to follow the rituals).

TIA

Mishu~

aq_mishu:
my final product, ethernetStreamOut will become like this: <100010010>

for which you would need a char array of size 12 to fit those 11 plus the null terminator.

  1. learn to indent properly
  2. you need to put a char in each position of the array:
void outputReport(){
  memset(socketTxStream, 0, sizeof(socketTxStream)); // Clear contents of Buffer
  
  sbcStrRS232_tx[0] = '1';
  if(askedToOpen){
    sbcStrRS232_tx[1] = '1';
  } 
  else{
    sbcStrRS232_tx[1] = '0';
  }
  // and so on...

or less wordy:

void outputReport(){
  memset(socketTxStream, 0, sizeof(socketTxStream)); // Clear contents of Buffer
  
  sbcStrRS232_tx[0] = '1';
  sbcStrRS232_tx[1] = askedToOpen? '1' : '0';

aq_mishu:

void strcat_c( char *dest, int destlen, char c )

{
  int len = strlen(dest);
  if( len < (destlen-1) ){
    dest[len++]= c;
    dest[len]= ‘\0’;
  }
}

you ar just posting arbitrary code now?

aq_mishu:
But thing is coming...

maybe there is a native-speaking section of the forum for whatever language you really speak?

it may be more productive.

Suggestion in post#10 is the best option so far

surepic:
Suggestion in post#10 is the best option so far

Of 5? (6 now)