Skip to main content
Post Closed as "Not suitable for this site" by Michel Keijzers, ocrdu, timemage, Majenko

I have written a small test code for Arduino Uno which is as follows:

unsigned char tes[4];
char testing[4]; 

void setup() {
    Serial.begin(9600);
    for (int i = 0; i < 4; i++)
  {
        testing[i] = i;
        tes[i] = i;
    }
    for (int i = 0; i < 4; i++)
  {
        Serial.print("unsigned char is: ");
        Serial.println(tes[i]);
        Serial.print("char is: ");
        Serial.println(testing[i]);
  }
  
 }
}

void loop() {
}

and the output which I get is as follows

unsigned char is: 0
char is: 
unsigned char is: 1
char is: 
 unsigned char is: 2
char is: 
unsigned char is: 3
char is: 

Can someone help me out why is the difference in output.

I have written a small test code for Arduino Uno which is as follows:

unsigned char tes[4];
char testing[4];
void setup() {
 Serial.begin(9600);
 for(int i = 0; i < 4; i++)
  {
 testing[i] = i;
 tes[i] = i;
}
for(int i = 0; i < 4; i++)
 {
Serial.print("unsigned char is: ");
Serial.println(tes[i]);
Serial.print("char is: ");
Serial.println(testing[i]);
  }
  
 
}

void loop() {
}

and the output which I get is as follows

unsigned char is: 0
char is: 
unsigned char is: 1
char is: 
 unsigned char is: 2
char is: 
unsigned char is: 3
char is: 

Can someone help me out why is the difference in output.

I have written a small test code for Arduino Uno which is as follows:

unsigned char tes[4];
char testing[4]; 

void setup() {
    Serial.begin(9600);
    for (int i = 0; i < 4; i++) {
        testing[i] = i;
        tes[i] = i;
    }
    for (int i = 0; i < 4; i++) {
        Serial.print("unsigned char is: ");
        Serial.println(tes[i]);
        Serial.print("char is: ");
        Serial.println(testing[i]);
    }
}

void loop() {
}

and the output which I get is as follows

unsigned char is: 0
char is: 
unsigned char is: 1
char is: 
unsigned char is: 2
char is: 
unsigned char is: 3
char is: 

Can someone help me out why is the difference in output.

Became Hot Network Question
Source Link
Maaz Sk
  • 345
  • 3
  • 16

Difference between char array and unsigned char array

I have written a small test code for Arduino Uno which is as follows:

unsigned char tes[4];
char testing[4];
void setup() {
 Serial.begin(9600);
 for(int i = 0; i < 4; i++)
 {
 testing[i] = i;
 tes[i] = i;
}
for(int i = 0; i < 4; i++)
{
Serial.print("unsigned char is: ");
Serial.println(tes[i]);
Serial.print("char is: ");
Serial.println(testing[i]);
  }
  

}

void loop() {
}

and the output which I get is as follows

unsigned char is: 0
char is: 
unsigned char is: 1
char is: 
 unsigned char is: 2
char is: 
unsigned char is: 3
char is: 

Can someone help me out why is the difference in output.