while-loop

while loop extremely slow read file

£可爱£侵袭症+ 提交于 2019-12-01 09:42:49
问题 I have a while loop that that reads in a ftp log file and puts it into an array so I'll be able to search through the array and match up/search for a flow. Unfortunately the while loop is taking forever to get through the file, it is a very large file but there must be another faster way of doing this. # read file into array for original search results while read FTP_SEARCH do ogl_date[count]=`echo $FTP_SEARCH | awk '{print $1, $2}'` ogl_time[count]=`echo $FTP_SEARCH | awk '{print $3}'` ogl

Why does the message print twice?

狂风中的少年 提交于 2019-12-01 09:38:11
I am creating a simple Tic Tac Toe for C, and here is a particular function which I am having a problem with. This is supposed to let the user select 'X' or 'O', and for the most art it works. However, if I enter a wrong symbol, it prints the statement: "Invalid symbol, please re-enter: " twice. Why and how can I fix this? char assign(void) { char user; printf("Would you like to be X or O (Enter your choice): "); user=getchar(); while(user != 'X' && user != 'x' && user != 'O' && user != 'o') { printf("Invalid symbol, please re-enter: "); user=getchar(); } if(user == 'O' || user == 'o') return(

Why does the message print twice?

匆匆过客 提交于 2019-12-01 09:25:57
问题 I am creating a simple Tic Tac Toe for C, and here is a particular function which I am having a problem with. This is supposed to let the user select 'X' or 'O', and for the most art it works. However, if I enter a wrong symbol, it prints the statement: "Invalid symbol, please re-enter: " twice. Why and how can I fix this? char assign(void) { char user; printf("Would you like to be X or O (Enter your choice): "); user=getchar(); while(user != 'X' && user != 'x' && user != 'O' && user != 'o')

How to stop a while loop

我与影子孤独终老i 提交于 2019-12-01 08:35:34
This while loop never ends. For example, when i enter a wrong password it will keep on going to the "incorrect password" part over and over again. Logo(); inFile.open("UsernamePassword.txt"); if (!inFile) cout << "Unable to Open File"; else { cout << endl << endl << endl; cout << " Please enter username: "; cin >> user; cout << " Please enter password: "; cin >> pass; while (username != user) { inFile >> username >> password; if (user == username && pass == password) { cout << endl; cout << "Welcome to CherryLunch!" << endl; system("pause"); system("cls"); MainMenu(); } else { cout << endl;

Displaying table data column-wise in a while loop

对着背影说爱祢 提交于 2019-12-01 08:34:22
问题 I'm attempting to retrieve all that data from a database, put it in a table (more than one table if necessary) and display them column-wise in lots of 4 split across multiple pages. I would like to know how I would get the tables to display horizontally e.g. Table Header Table Header Table Header Table Data Table Data Table Data Table Data Table Data Table Data Rather than: Table Header Table Data Table Data Table Header Table Data etc. Here is the code so far: // While loop that will display

Java, need a while loop to reach eof. i.e.while !eof, keep parsing

*爱你&永不变心* 提交于 2019-12-01 08:33:22
问题 I currently have a working parser. It parses a file once(not what I want it to do) and then outputs parsed data into a file. I need it to keep parsing and appending to the same output file until the end of the input file. Looks something like this. try { // my code parsing the data and appending to eof of output. (works) } catch (EOFException eof){ } Everything is done except the while loop. It only parses once when I need it to keep parsing. I'm looking for a while loop function to reach eof

Java Scanner won't “finish” reading input

血红的双手。 提交于 2019-12-01 08:06:02
问题 I've been having trouble using java's Scanner class. I can get it to read my input just fine, but the problem is when I want to output something. Given multiple lines of input, I want to print just ONE line when all the input has been read completely. Here's the code I use for reading input: public static void main(String[] args){ Scanner scanner = new Scanner(System.in); //scanner reads block of input while(scanner.hasNextLine()){ //body of loop goes here String s = scanner.nextLine();

Mysql fetch array, table results

百般思念 提交于 2019-12-01 08:01:31
i'm pretty new to this and not sure how should i do it, I've got a database with a column called "names" how can i make it display in so? <tr> <td width="270px">Henry</td> <td width="270px">Jeffrey</td> <td width="270px">Hansel</td> </tr> <tr> <td width="270px">Michelle</td> <td width="270px">Jackson</td> <td width="270px">Ivan</td> </tr> I only know how i should do it if the records goes one after another vertically. $result = mysql_query('SELECT * FROM member'); while($row = mysql_fetch_array($result)) { echo' <tr> <td width="270px">'.$row['names'].'</td> <td width="270px">Jeffrey</td> <td

Using FOR loop in VHDL with a variable

橙三吉。 提交于 2019-12-01 07:38:28
Is there any possible way to create a for loop in the form: for i in 0 to some_var loop // blah,blah end loop; If not, is there any alternative way to create the same loop? Since While loops allows to use variable as the limit, but they are not synthesizeable in my project. Thanks in Advance, Bojan Matovski The variable works just fine for testbench applications. For synthesis you can get the same effect by using a static range and an exit condition. Set the range to be the maximum you will need. for i in 0 to MAX_VALUE loop exit when i = some_var ; // blah,blah end loop; If your synthesis

Lerp between two values over time

眉间皱痕 提交于 2019-12-01 07:29:47
问题 I'm trying to reduce a float by a time value, i'm using Unity and stopping time Time.timeScale = 0f; so can not use Time.deltaTime so using 'Time.realtimeSinceStartup' in a while loop, i read in the master volume variable from a global script that the player can set in game between 0 - 1 so say i read in 0.6 and i want to lower the volume to 0 in 2 second how do i get the percentage to keep reducing the volume by ? Here is my code .. private IEnumerator VolumeDown () { float volumeIncrease =