snipplets.dev/snipplets/code/Arduino/variables_sizes.ino

55 lines
1.4 KiB
Arduino
Raw Normal View History

/**
* Скетч, который выводит в Serial размер типов переменных в байтах
*/
2023-09-03 11:41:30 +03:00
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() {
//
}