search

Home  >  Q&A  >  body text

Linux’s next classic C language interview question

If you use the GCC compiler to execute the following program under Linux, what is the output result?

#include<stdio.h>
int main(){
    enum color{RED,BLUE,GREEN=-2,YELLOW,PINK};
    printf("%d  %d",BLUE,PINK);
    return 0;
}

I don’t understand very well. What’s the special syntax for enum type data in C language?

Original question source: Several classic interview questions in C language under Linux

扔个三星炸死你扔个三星炸死你2716 days ago1203

reply all(1)I'll reply

  • 欧阳克

    欧阳克2017-06-26 11:01:04

    When GREEN=-2, the subsequent data will be enumerated from -1, so RED=0, BLUE=1, GREEN=-2, YELLOW=-1, PINK=0

    reply
    0
  • Cancelreply