int main(void) { int rule = 0; temptype temp = 0; char cont[4]; memset(cont, '\0', 4); printf("Welcome to tempconvert!\n\n"); start: // first of all, show all the menu and shit printf( "Please choose the scale of your current datum.\n" "1)Kelvin\n" "2)Celsius\n" "3)Fahrenheit\n" "4)Rankine\n\n" ); printf( "Please choose the scale you want to convert it to.\n" "5)Kelvin\n" "6)Celsius\n" "7)Fahrenheit\n" "8)Rankine\n\n" ); printf("To exit type \"0\".\n\n"); printf("Now type both selections in order (least to greatest) and press ENTER.\n"); // get the selection scanf("%d", &rule); // check the selection switch(rule) { case 0: return 0; break; case 16: // K to C temp = ask_temp(); // insert here any way to check for the temp entered printf("%.2f K in C is %.2f\n", temp, K_C(temp)); break; case 17: // K to F temp = ask_temp(); printf("%.2f K in F is %.2f\n", temp, K_F(temp)); break; case 18: // K to R temp = ask_temp(); printf("%.2f K in R is %.2f\n", temp, K_R(temp)); break; case 25: // C to K temp = ask_temp(); printf("%.2f C in K is %.2f\n", temp, C_K(temp)); break; case 27: // C to F temp = ask_temp(); printf("%.2f C in ºF is %.2f\n", temp, C_F(temp)); break; case 28: // C to R temp = ask_temp(); printf("%.2f C in R is %.2f\n", temp, C_R(temp)); break; case 35: // F to K temp = ask_temp(); printf("%.2f F in K is %.2f\n", temp, F_K(temp)); break; case 36: // F to C temp = ask_temp(); printf("%.2f F in C is %.2f\n", temp, F_C(temp)); break; case 38: // F to R temp = ask_temp(); printf("%.2f F in R is %.2f\n", temp, F_R(temp)); break; case 45: // R to K temp = ask_temp(); printf("%.2f R in K is %.2f\n", temp, R_K(temp)); break; case 46: // R to C temp = ask_temp(); printf("%.2f R in C is %.2f\n", temp, R_C(temp)); break; case 47: // R to F temp = ask_temp(); printf("%.2f R in F is %.2f\n", temp, R_F(temp)); break; default: // not valid printf("Not a valid option. Bye.\n"); break; } printf("Convert something else? (Y/N): "); scanf("%3s", &cont); if(cont[0] == 'y' || cont[0] == 'Y') { rule = temp = 0; memset(cont, '\0', 4); putchar('\n'); goto start; } return 0; }
#define BASE 0 #define SYMB 1 #define MDIA 2 LAYOUT( [BASE] = LAYER( K(US_SC('=')), K(US_SC('1')), K(US_SC('2')), K(US_SC('3')), K(US_SC('4')), K(US_SC('5')), K(US_SC(L_C('-'))), K(US_SC(DELETE)), K(US_SC('q')), K(US_SC('w')), K(US_SC('e')), K(US_SC('r')), K(US_SC('t')), L(GOTO, SYMB), K(US_SC(BKSP)), K(US_SC('a')), K(US_SC('s')), K(US_SC('d')), K(US_SC('f')), K(US_SC('g')), HTA(K(US_SC(L_SHIFT)), K(US_SC('('))), THA(K(US_SC('z')), K(US_SC(L_CTRL))), K(US_SC('x')), K(US_SC('c')), K(US_SC('v')), K(US_SC('b')), HTA(K(US_SC(L_C(L_S(L_A(L_G(0)))))), K(US_SC('['))), HTA(L(VISIT, SYMB), K(US_SC('`'))), K(US_SC('\'')), K(US_SC(L_A(L_S(0)))), K(US_SC(LEFT)), K(US_SC(RIGHT)), HTA(K(US_SC(L_ALT)), K(US_SC(APP))), K(US_SC(L_GUI)), K(US_SC(HOME)), K(US_SC(' ')), LEADER_KEY, K(US_SC(END)), K(US_SC(R_C('='))), K(US_SC('6')), K(US_SC('7')), K(US_SC('8')), K(US_SC('9')), K(US_SC('0')), K(US_SC('-')), L(GOTO, SYMB), K(US_SC('y')), K(US_SC('u')), K(US_SC('i')), K(US_SC('o')), K(US_SC('p')), K(US_SC('\\')), K(US_SC('h')), THA(K(US_SC('j')), K(US_SC(R_ALT))), K(US_SC('k')), K(US_SC('l')), THA(K(US_SC(';')), L(VISIT, MDIA)), THA(K(US_SC('\'')), K(US_SC(R_GUI))), HTA(K(US_SC(R_C(R_S(R_A(0))))), K(US_SC(']'))), K(US_SC('n')), K(US_SC('m')), K(US_SC(',')), K(US_SC('.')), THA(K(US_SC('/')), K(US_SC(R_CTRL))), HTA(K(US_SC(R_SHIFT)), K(US_SC(')'))), K(US_SC(UP)), K(US_SC(DOWN)), K(US_SC('[')), K(US_SC(']')), HTA(L(VISIT, SYMB), K(US_SC('-'))), K(US_SC(R_ALT)), HTA(K(US_SC(R_CTRL)), K(US_SC(ESC))), K(US_SC(PG_UP)), K(US_SC(PG_DN)), HTA(L(VISIT, SYMB), K(US_SC(TAB))), K(US_SC(ENTER)) ), [SYMB] = LAYER( NO_ACTION, K(US_SC(F1)), K(US_SC(F2)), K(US_SC(F3)), K(US_SC(F4)), K(US_SC(F5)), NO_ACTION, NO_ACTION, NO_ACTION, NO_ACTION, NO_ACTION, NO_ACTION, NO_ACTION, L(GOTO, BASE), NO_ACTION, K(US_SC('1')), K(US_SC('2')), K(US_SC('3')), K(US_SC('4')), K(US_SC('5')), NO_ACTION, K(US_SC('6')), K(US_SC('7')), K(US_SC('8')), K(US_SC('9')), K(US_SC('0')), NO_ACTION, NO_ACTION, NO_ACTION, NO_ACTION, K(US_SC(L_C(PG_UP))), K(US_SC(L_C(PG_DN))), NO_ACTION, NO_ACTION,