Skip to main content
added 100 characters in body
Source Link
Cyber_Star
  • 117
  • 2
  • 8

I'm trying to convert a char array to a char. i used this code

char code[4] = {'1','2','3','4'};

char strcode[4];



void setup()
{
    Serial.begin(9600);
}


void loop()
{
    memcpy(strcode, code, 4);
    Serial.println(strcode);
    Serial.println("done");
    delay(1000);
}

But for some reason when i read my serial monitor i get this:

1234
done

Why are there 2 squares behind it? Am I doing it wrong?

EDIT: For some reason stackexchange doesn't show the 2 squares but there are 2 squares behind 1234

I'm trying to convert a char array to a char. i used this code

char code[4] = {'1','2','3','4'};

char strcode[4];



void setup()
{
    Serial.begin(9600);
}


void loop()
{
    memcpy(strcode, code, 4);
    Serial.println(strcode);
    Serial.println("done");
    delay(1000);
}

But for some reason when i read my serial monitor i get this:

1234
done

Why are there 2 squares behind it? Am I doing it wrong?

I'm trying to convert a char array to a char. i used this code

char code[4] = {'1','2','3','4'};

char strcode[4];



void setup()
{
    Serial.begin(9600);
}


void loop()
{
    memcpy(strcode, code, 4);
    Serial.println(strcode);
    Serial.println("done");
    delay(1000);
}

But for some reason when i read my serial monitor i get this:

1234
done

Why are there 2 squares behind it? Am I doing it wrong?

EDIT: For some reason stackexchange doesn't show the 2 squares but there are 2 squares behind 1234

Source Link
Cyber_Star
  • 117
  • 2
  • 8

Converting array to char

I'm trying to convert a char array to a char. i used this code

char code[4] = {'1','2','3','4'};

char strcode[4];



void setup()
{
    Serial.begin(9600);
}


void loop()
{
    memcpy(strcode, code, 4);
    Serial.println(strcode);
    Serial.println("done");
    delay(1000);
}

But for some reason when i read my serial monitor i get this:

1234
done

Why are there 2 squares behind it? Am I doing it wrong?