online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <stdio.h> #include <string.h> #include <stdbool.h> #include <stdint.h> #define MAX_POINTS_CNT 10 typedef struct temp_profiles_data { uint8_t id; char name[30]; bool is_valid; uint16_t temp[MAX_POINTS_CNT]; uint16_t duration[MAX_POINTS_CNT]; } temp_profiles_data_t; typedef struct temp_profile { temp_profiles_data_t profile[5]; // temperature profile } temp_profile_t; typedef struct heater_plates { temp_profile_t plate[2]; // 0 - bottom, 1 - top } heater_plates_t; int main(void) { /* temp_profile_t heater[] = { // массив структур {0, "Profile 1", true, {0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0}, 1, "Profile 2", true, {0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0}, 2, "Profile 3", true, {0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0}, 3, "Profile 4", true, {0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0}, 4, "Profile 5", true, {0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0} }, {0, "Profile 1", true, {0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0}, 1, "Profile 2", true, {0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0}, 2, "Profile 3", true, {0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0}, 3, "Profile 4", true, {0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0}, 4, "Profile 5", true, {0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0} }, }; printf("sizeof temp_profile_t: %ld\n", sizeof(temp_profile_t)); printf("sizeof heater_plates_t: %ld\n", sizeof(heater_plates_t)); */ heater_plates_t heaters; char dfltProfNames[][10] = {"Profile 1", "Profile 2", "Profile 3", "Profile 4", "Profile 5"}; for (uint8_t j = 0; j < 2; j++) { for (uint8_t h = 0; h < 5; h++) { heaters.plate[j].profile[h].id = h; printf("heaters.plate[%d].profile[%d].id: %d\n", j, h, heaters.plate[j].profile[h].id); strncpy(heaters.plate[j].profile[h].name, dfltProfNames[h], sizeof(heaters.plate[j].profile[h].name) - 1); printf("heaters.plate[%d].profile[%d].name: %s\n", j, h, heaters.plate[j].profile[h].name); heaters.plate[j].profile[h].is_valid = true; printf("heaters.plate[%d].profile[%d].is_valid: %s\n", j, h, heaters.plate[j].profile[h].is_valid ? "true" : "false"); memset(heaters.plate[j].profile[h].temp, 0, MAX_POINTS_CNT * sizeof(uint16_t)); for (uint8_t cnt1 = 0; cnt1 < MAX_POINTS_CNT; cnt1++) { printf("heaters.plate[%d].profile[%d].temp[%d]: %u\n", j, h, cnt1, heaters.plate[j].profile[h].temp[cnt1]); } memset(heaters.plate[j].profile[h].duration, 0, MAX_POINTS_CNT * sizeof(uint16_t)); for (uint8_t cnt2 = 0; cnt2 < MAX_POINTS_CNT; cnt2++) { printf("heaters.plate[%d].profile[%d].duration[%d]: %u\n", j, h, cnt2, heaters.plate[j].profile[h].temp[cnt2]); } printf("\n"); } } printf("sizeof temp_profile_t: %ld\n", sizeof(temp_profile_t)); printf("sizeof heater_plates_t: %ld\n", sizeof(heater_plates_t)); return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue