0

I'm trying to understand what is the role of the do...while loop in this macro.

#define err_msg(msg) \
    do { \
        perror(msg); \
        exit(1); \
    } while (0)

Could you help me figure it out?

Jonathan Leffler
  • 698,132
  • 130
  • 858
  • 1,229
  • That is used to encapsulate a block of code within a `{ }` pair, in `C` `do-while` loop with condition `0` will be executed once. – Darth-CodeX Apr 09 '22 at 12:40

0 Answers0