infinite-loop

Infinite loop code in C

回眸只為那壹抹淺笑 提交于 2019-12-11 03:39:06
问题 In the below program I try to input a number between 1 to 100 but if I enter a 'character' or "string" ( like s or sova ) during the execution time of scanf() statement it creates a infinite loop. so I try to do .... when I input a string or a character it shown me a message like "wrong value entered. enter again" and it will enter again... Thanx; #include<stdio.h> int main() { int a; scanf("%d",&a); while(!(a>=1&&a<=100)) { printf("wrong value entered. enter again\n"); scanf("%d",&a); }

While searching for .pst files FOR keeps looping when it reaches a hidden shortcut folder

≡放荡痞女 提交于 2019-12-11 02:12:24
问题 The following command creates an infinite loop which is not what I want since I am iterating through files and it needs to end sometime... Here is what I have: cd C:\ FOR /R %i IN (*.pst) do @echo %i See what happens is that when it reaches AppData and finds a .pst (in AppData\Local\Microsoft\Outlook) there is a shortcut folder inside AppData\Local called "Application Data" which loops back to AppData\Local but keeps adding it's name to the address like so: %AppData%\Local\Application Data

C# UnhandledException from another thread keeps looping

守給你的承諾、 提交于 2019-12-11 01:16:56
问题 I have a thread that is very simple. The only thing the Thread object does is throw new Exception(); . The reason why I did that is because I needed to test what happens if a exception happens in a separate thread in my application. I have tested this with a "real" run time exception and my problem is the same. What I do before I call the thread is: AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException; Application.Current.DispatcherUnhandledException +=

Infinite loop when I combine a button click and an asynchronous Contacts call

有些话、适合烂在心里 提交于 2019-12-11 00:56:58
问题 I have problem when i combines a button click event with a asynchronous call of Contacts on the phone (WP7). The problem is that the SearchCompleted event for the async Contacts call is not run before the Click event is finnished. This will lead to a infinite loop while waiting for that the async call should completes. In my simplified code example I have a checkbox and a button. When the button is pressed a click event is raised. If the checkbox is checked then an asynchronous SearchAsync

Do infinite loops of JavaScript crash the browsers these days?

自古美人都是妖i 提交于 2019-12-10 21:42:58
问题 I am learning JavaScript and am quite new in Programming and happened to land upon these infinite loops which were said to go on forever and crash the browser, but when I created one with these codes: i=0; while (i<10) {document.write(i);} The browser just kept on going to load it and never did but the browser didn't crash? So is it that the browsers these days are powerful enough to withstand infinite loops, or do I need a different infinite loop? 回答1: Yes , Infinite loops do still crash

How can I remove the while(true) from my loop in Java?

强颜欢笑 提交于 2019-12-10 21:18:44
问题 I've heard that using while(true) is a bad programming practice. So, I've written the following code to get some numbers from a user (with default values). However, if the user happens to type in -1, then it will quit the program for them. How should this be written then without a while(true)? I can think of a condition to make the while loop go off that will get caught right away without continuing on until the next iteration? Here is how I have it now: public static void main(String[] args)

how can I detect infinite loops in python

放肆的年华 提交于 2019-12-10 20:06:18
问题 I am learning Python 3 and working on an exercise that calls for writing a Python program which simulates/reads a BASIC program as input. I am stuck on writing the part of the Python program that should detect infinite loops. Here is the code I have so far: def execute(prog): while True: location = 0 if prog[location] == len(prog) - 1: break return "success" getT = prog[location].split() T = len(getT) - 1 location = findLine(prog, T) visited = [False] * len(prog) Here, prog is a list of

Why is Ruby's loop command slower than while true?

北战南征 提交于 2019-12-10 16:44:47
问题 Ruby has a built-in loop command that executes the block following it forever (or until stopped by break ). However, when comparing it against the functionally similar while true , it is significantly slower: require "benchmark/ips" NUMBER = 100_000_000 def fast index = 0 while true break if index > NUMBER index += 1 end end def slow index = 0 loop do break if index > NUMBER index += 1 end end Benchmark.ips do |x| x.report("While Loop") { fast } x.report("Kernel loop") { slow } x.compare! end

Infinite loops using 'for' in Python [duplicate]

谁都会走 提交于 2019-12-10 14:18:38
问题 This question already has answers here : Is there an expression for an infinite generator? (7 answers) Closed last year . Why does this not create an infinite loop? a=5 for i in range(1,a): print(i) a=a+1 or this for i in range(1,4): print(i) i=i-1 or this for i in range(1,4): print(i) i=1 Is there any way we can create infinite loops using a for loop? I know there is the while loop for that but I was just curious. 回答1: range is a class, and using in like e.g. range(1, a) creates an object of

Loop every x seconds based on process speed

穿精又带淫゛_ 提交于 2019-12-10 13:22:20
问题 I am implementing a basic (just for kiddies) anti-cheat for my game. I've included a timestamp to each of my movement packets and do sanity checks on server side for the time difference between those packets. I've also included a packet that sends a timestamp every 5 seconds based on process speed. But it seems like this is a problem when the PC lags. So what should I use to check if the process time is faster due to "speed hack"? My current loop speed check on client: this_time = clock();