do-while

Test loops at the top or bottom? (while vs. do while) [closed]

只谈情不闲聊 提交于 2019-12-18 09:45:59
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . When I was taking CS in college (mid 80's), one of the ideas that was constantly repeated was to always write loops which test at the

VBA - Do While Loop returns Dir <Invalid procedure call or argument>

喜你入骨 提交于 2019-12-18 09:44:18
问题 I am running a loop through a folder in order to get the complete filename address (folders address + file name and extension). I am using the following, but at some point the Dir value is <Invalid procedure call or argument> recsFolder = Functions.GetFolder("C:\") recfile = recsFolder & "\" & Dir(recsFolder & "\*.rec*") Do While Len(recfile) > 0 recfile = recsFolder & "\" & Dir Loop The error is thrown before the loop as completed reading all the files. EDIT: another approach and Dir is

Function that prompts user for integer value and checks for valid input

给你一囗甜甜゛ 提交于 2019-12-18 07:22:28
问题 I currently am stuck on a small part of an assignment I need to do. One requirement of the assignment is "Call a function that prompts the user for each of the values of the coefficients a, b, and c for the quadratic equation and returns the value entered, with error checking for a valid input (scanf returned a value)." and I can't figure out how to do this. I can easily prompt the user for input and I can check if it is valid input, but I don't know how to turn this into a function. My

Scope of declarations in the body of a do-while statement

你说的曾经没有我的故事 提交于 2019-12-18 04:50:55
问题 In Why can't you declare a variable inside a do while loop? the OP asks why a declaration in the while-condition of a do-while loop isn't in scope in the do-statement. That would be very unnatural as C/C++ generally follow a "declaration-at-top-of-scope" pattern. But what about the converse - why not extend the scope of any declaration in the do-statement to the while-condition. That would allow int i; do { i = get_data(); // whatever you want to do with i; } while (i != 0); to be shortened

Scanner input accepting Strings skipping every other input inside a while loop. [duplicate]

烂漫一生 提交于 2019-12-17 21:23:37
问题 This question already has an answer here : How to use java.util.Scanner to correctly read user input from System.in and act on it? (1 answer) Closed 4 years ago . Alright, so the code is pretty straight forward. Generic class ourSet, that takes in some elements, puts it in a LinkedList, and does some functions on the two sets. My problem is actually quite unrelated the general concept of the project, its more in the "user input interface" I've created. I want it to take in some Strings and

Reading key/value parameters from a file into a shell script

落爺英雄遲暮 提交于 2019-12-17 07:55:48
问题 I've got my script working almost. The goal of this is to take defined values from a file and then populate these valeus in a shell script at runtime. Please take a look at what i have here... The first file: ab.sh #!/bin/bash USER_TYPE=$1 #IDENTIFY USER TYPE TYPE1,TYPE2,TYPE3,TYPE4 USERNAME=$2 PERMISSION_TYPE=$3 #IDENTIFY PERMISSION TYPE SELECT,UPDATE,DELETE,INSERT TARGET_USER=$4 TARGET_TABLE=$5 if [ $USER_TYPE == 'TYPE1' ] then cat Parameters.conf |while read USERNAME do sqlplus / as sysdba

Reading key/value parameters from a file into a shell script

徘徊边缘 提交于 2019-12-17 07:55:17
问题 I've got my script working almost. The goal of this is to take defined values from a file and then populate these valeus in a shell script at runtime. Please take a look at what i have here... The first file: ab.sh #!/bin/bash USER_TYPE=$1 #IDENTIFY USER TYPE TYPE1,TYPE2,TYPE3,TYPE4 USERNAME=$2 PERMISSION_TYPE=$3 #IDENTIFY PERMISSION TYPE SELECT,UPDATE,DELETE,INSERT TARGET_USER=$4 TARGET_TABLE=$5 if [ $USER_TYPE == 'TYPE1' ] then cat Parameters.conf |while read USERNAME do sqlplus / as sysdba

'do…while' vs. 'while'

拥有回忆 提交于 2019-12-17 03:04:07
问题 Possible Duplicates: While vs. Do While When should I use do-while instead of while loops? I've been programming for a while now (2 years work + 4.5 years degree + 1 year pre-college), and I've never used a do-while loop short of being forced to in the Introduction to Programming course. I have a growing feeling that I'm doing programming wrong if I never run into something so fundamental. Could it be that I just haven't run into the correct circumstances? What are some examples where it

'do…while' vs. 'while'

只愿长相守 提交于 2019-12-17 03:04:04
问题 Possible Duplicates: While vs. Do While When should I use do-while instead of while loops? I've been programming for a while now (2 years work + 4.5 years degree + 1 year pre-college), and I've never used a do-while loop short of being forced to in the Introduction to Programming course. I have a growing feeling that I'm doing programming wrong if I never run into something so fundamental. Could it be that I just haven't run into the correct circumstances? What are some examples where it

Do…While() loop does not work fine

依然范特西╮ 提交于 2019-12-14 04:12:38
问题 I am prompting the user to enter data regarding cars. The Do...while() loop I am using works fine the first time, then does not work properly after the first time. The code is bellow, and I am using Dev-C++. Thank you for your help and time. #include <iostream> #include<conio.h> #include<cstring> #include<fstream> #include <iomanip.h> using namespace std; int main() { char manufacturer[16], model[16], year[10], miles[10], car_cost[12]; char response; ofstream OS ("usedcars.txt", ios::out);