snipplets.dev/snipplets/code/Arduino/variable_sizes.ino
2023-09-03 11:41:30 +03:00

51 lines
1.2 KiB
C++

void setup() {
Serial.begin(9600);
size_t size_variable;
int example_int;
unsigned int example_uint;
signed int example_sint;
unsigned long example_ulint;
float example_float;
double example_double;
char example_char;
char * example_string;
size_variable = sizeof(example_int);
Serial.print("int bytes size: " );
Serial.println(size_variable);
size_variable = sizeof(example_uint);
Serial.print("unsigned int bytes size: " );
Serial.println(size_variable);
size_variable = sizeof(example_sint);
Serial.print("signed int bytes size: " );
Serial.println(size_variable);
size_variable = sizeof(example_ulint);
Serial.print("unsigned long bytes size: " );
Serial.println(size_variable);
size_variable = sizeof(example_float);
Serial.print("float bytes size: " );
Serial.println(size_variable);
size_variable = sizeof(example_double);
Serial.print("double bytes size: " );
Serial.println(size_variable);
size_variable = sizeof(example_char);
Serial.print("char bytes size: " );
Serial.println(size_variable);
size_variable = sizeof(example_string);
Serial.print("char * bytes size: " );
Serial.println(size_variable);
}
void loop() {
//
}