120. Copy Semantics-II

Question.2

A simple config struct with no pointers is copied:

struct GpioConfig {
   uint8_t port;
   uint8_t pin;
   uint8_t mode;
};

GpioConfig cfg1 = {2, 5, 1};
GpioConfig cfg2 = cfg1;
cfg2.mode = 0;
printf("%d", cfg1.mode);

What is the output?

Need Help? Refer to the Quick Guide below

Select Answer