编程学习网为您整理以下代码实例,主要实现:在枚举中定义转义,使用enum来控制循环,希望可以帮到各位朋友。
#include <stdio.h>
enum escapes { BELL = '\a', BACKSPACE = '\b', TAB = '\t',
NEWliNE = '\n', VTAB = '\v', RETURN = '\r' };
enum months { JAN = 1, FEB, MAR, APR, MAY, JUN,
Jul, AUG, SEP, OCT, NOV, DEC };
/* FEB is 2, MAR is 3, etc. */
int main() {
printf("BELL, BACKSPACE, TAB, NEWliNE, VTAB, RETURN\n");
printf("%o %o %o %o %o %o\n",BELL, BACKSPACE, TAB, NEWliNE, VTAB, RETURN);
for (int i = JAN; i <= DEC; i++)
printf("%d ", i);
printf("\n");
return 0;
}
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!