The C, Z, S and O flags are all stored in the status register eflags (enhanced flags) of the i386 architecture. However, it is not always convenient to extract the corresponding bits from 32-bit register. As s result, it is handy to define a gdb macro to interepret the flag bits for us.
While you can copy-and-paste this into gdb every time it is started, it is more convenient to put this definition in a file called .gdbinit in the same directory that you will start gdb. To display the flags, simply use the command flags in gdb.
Iff a flag is set, it is displayed when the command is executed.