do-while

grep output placed into a while loop

自古美人都是妖i 提交于 2020-03-28 06:15:14
问题 I currently have my grep output configured to place everything in a file, i'm trying to set something up where a file will not need to be created. func_database () { egrep "^[0-9]" file.txt | egrep "/ON /" | sed s/-[^@]*$// > /users/home/myhome/log/test.txt } func_database while read -r line ; do echo "Database $line Area a:" python amgr.py status $line a echo "" echo "Database $line Area b:" python amgr.py status $line b echo "" echo "Database $line Area c:" python amgr.py status $line c

Why is the while loop never ending?

拥有回忆 提交于 2020-02-26 04:00:09
问题 I am trying to ask scanner input until I get a valid answer but my while loop is not ending. First I am asking for user input, and then if the input is valid I am printing out the coordinates and if it is not valid I am throwing an error and asking for input again. This is my code: public static String[] positionQuery(int dim, Scanner test_in) { String[] coordinates; Scanner stdin = new Scanner(System.in); System.out.println("Provide origin and destination coordinates."); System.out.println(

Do - while goes into an infinite loop

不羁岁月 提交于 2020-02-23 07:16:08
问题 Im trying to add an input validation to this menu. When the user enters eg: 'a' or any input that is not a integer and with the given range, it must execute the catch block and loop again to prompt the user to enter again but instead it keeps looping infinitely after taking the input once. So it goes from executing the menu and just skipping over the input part and executes the catch block. Edit: it goes into infinite loop if i input anything that is not an integer. Scanner sc = new Scanner

C switch statement with do-while interleaved [duplicate]

烈酒焚心 提交于 2020-02-04 01:49:47
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How does Duff's device work? I am trying to understand how this is working. Any help would be appreciated. #include<stdio.h> void duff(int count) { int n=(count+7)/8; printf("n=%d count =%d\n",n,count%8); switch(count%8){ case 0: do{ printf("case 0\n"); case 7: printf("case 7\n"); case 6: printf("case 6\n"); case 5: printf("case 5\n"); case 4: printf("case 4\n"); case 3: printf("case 3\n"); case 2: printf("case

In VBA code,how to add values to a listbox using for each cell approach with defining a range End(XlDown)?

瘦欲@ 提交于 2020-01-24 00:51:07
问题 I have created a macro file with Forms and Word to Excel. In this coding fewthings are not working as per my expectation. Get unique Employee Name from Excel data base. I want to add unique employee names from excel database and get is saved in a sheet. After that those values to be added to list box. Here i cannot define a range like "A1:A10".. I want to choose the data from A1 to end data. If for each cell approach will not work, please help in do while approach I need help in defining the

do{}while(0) - macro safety

寵の児 提交于 2020-01-16 14:53:13
问题 We know that multiline macros have to be inclosed in a do while(0) loop for them to be safely included anywhere in the code. For example this is 100% safe: #define swap( a , b ) \ do \ { \ int t = a ; \ a = b ; \ b = t ; \ } \ while(0) I would like to know if it is also safe to have a macro with a part of the code outside of the loop, and if it isn't, in what circumstances could problems occur. #define swap( a , b ) \ int t ; \ //should be in the same scope where the macro was called and

scanf() in a do-while loop causes infinite loop even with test of input

依然范特西╮ 提交于 2020-01-11 12:22:03
问题 I have this: float a, b, c; int isInt; do { puts("Please enter three positive lengths:"); isInt = scanf(" %f %f %f", &a, &b, &c); } while(a <= 0 || b <= 0 || c <= 0 || isInt != 3); Let's say my input is 1 2 f , then a == 1 , b == 2 , and c == 0 . Even more, isInt == 2 , which makes me wonder why it doesn't loop normally again...? 回答1: The problem in your code is what you do (more specifically, what you do not do) when scanf(...) returns a number other than 3. Currently, your code continues

scanf() in a do-while loop causes infinite loop even with test of input

本小妞迷上赌 提交于 2020-01-11 12:20:27
问题 I have this: float a, b, c; int isInt; do { puts("Please enter three positive lengths:"); isInt = scanf(" %f %f %f", &a, &b, &c); } while(a <= 0 || b <= 0 || c <= 0 || isInt != 3); Let's say my input is 1 2 f , then a == 1 , b == 2 , and c == 0 . Even more, isInt == 2 , which makes me wonder why it doesn't loop normally again...? 回答1: The problem in your code is what you do (more specifically, what you do not do) when scanf(...) returns a number other than 3. Currently, your code continues

try catch in a do while loop

别等时光非礼了梦想. 提交于 2020-01-07 06:52:11
问题 The program asks for the user input for the double num 1 and double num 2 and if there is an exception I want it to ask again for the input of num 1 and num 2 public static void main (String[] args) { Scanner sc = new Scanner(System.in); double num1, num2; int error = 0; int text; System.out.print("Enter 4 "); text = sc.nextInt(); do{ try{ if(text == 4){ System.out.print("Enter number 1: "); num1 = sc.nextDouble(); System.out.print("Enter number 2: "); num2 = sc.nextDouble(); double quotient

QT do while loop

匆匆过客 提交于 2020-01-06 07:11:43
问题 I am learning QT these days and I wanted to test do while loop , the actual login works in normally, but in QT the application freezes .. I have defined randnum and guess in the header file ( public ) void MainWindow::on_pushButton_clicked() { srand (time(NULL)); randnum = rand() % 10 +1; do { guess = ui->spinBox->value(); if (guess < randnum) { ui->label->setText("try something big"); } else if (guess > randnum) { ui->label->setText("try something small"); } else ui->label->setText("YAY?");