Enum with Values in C
Level 4197 keystrokes
Defines an enum with explicit integer values for HTTP status codes.
C code
// Each constant gets an explicit value instead of 0, 1, 21enum HttpStatus {2 OK = 200,3 NOT_FOUND = 404,4 SERVER_ERROR = 5005};6 // Declare enum variable7enum HttpStatus status = NOT_FOUND;// %d prints the numeric value: 4048printf("Status code: %d\n", status);// Compare using enum constant name9if (status == NOT_FOUND) {10 printf("Page not found\n");11}Output
Status code: 404 Page not found
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this C code and how often they appear.
=× 6_× 4;× 4"× 4,× 3(× 3)× 3{× 2}× 2\× 2