1: #include "bmi.h" 2: int meny () 3: { 4: char *cmd = "Xdialog --title \"BMI-1.2.4\" --stdout --menu \"Your choice\" 0 0 0 \"1\" \"Calculate your BMI\" \"2\" \"See the BMI scale\" \"3\" \"Change your length\" \"4\" \"Watch eariler results\" \"5\" \"Erase previous results\" \"6\" \"See your max and min BMI\" \"7\" \"Print your log\" \"8\" \"What is my optimal weight?\" \"9\" \"Exit\"", buf[2048]; 5: FILE *ptr = popen(cmd, "r"); 6: //while (fgets(buf, BUFSIZ, ptr) != NULL) 7: fgets(buf, BUFSIZ, ptr); 8: pclose(ptr); 9: 10: int bufInt = atoi(buf); 11: bool err = true; 12: 13: for (int i = 0; i < 10; i++){ 14: if (bufInt == i) 15: err = false; 16: } 17: 18: if (err == true){ 19: beep(); 20: cerr << "An error was encountered. Probably, it has its reason in an old version" << endl; 21: cerr << "of dialog. BMI requires dialog >= 0.9xx. Make sure your dialog supports the" << endl; 22: cerr << "--stdout option." << endl; 23: endwin(); 24: exit(1); 25: } 26: 27: return (bufInt); 28: } 29: