9
votes
Accepted
How to quit when running into an infinite loop
Try CTRL-C, that should make your program stop whatever it is currently doing.
2
votes
Accepted
Infinite looping in hacker 1 - water
I like that you don't want to use CS50's tools and use tools that you are going to have available everywhere outside of CS50.
I was reviewing your code. I tried to solve it with a fflush(stdin) line, ...
2
votes
Infinite looping in hacker 1 - water
Yes, don't use scanf. You have a library that helps you avoid using scanf.
The reason is probably related to the fact that scanf still keeps the string you input in its buffer and it won't empty it, ...
1
vote
Accepted
Understanding infinite loop with while loop
while() will run as long as the condition inside is true. In your code, an integer >2 will make it an infinite loop because the condition will be forever true.
Alternatively, if you use if() ...
1
vote
PSET6 DNA Think I'm getting an infinite loop which is apparent when testing with every txt file after 4.txt
The proximate cause of the infinite loop is this while in the repeatss function:
while dna_str[j : j + len_str] in str_csv[i]:
curr_str += 1
j += len_str
In ...
1
vote
Accepted
won function does not seem to return true (even though it should)
Why do you loop till j < d - 1 not j < d? For board 3*3, you miss board[0][2] so should return false for board[1][0].
However, I do not understand why you are stack in an infinite loop. You ...
1
vote
Accepted
PSET3 Binary Search Function Infinite Loop
Seems you just misprinted.
Change
end = middle + 1
to
start = middle + 1
and it will work just fine.
1
vote
Accepted
pset5 compile but it's thinking too long so it must be wrong
Written based on the second code:
You are allocating multiple times, overwriting the pointer each time? valgrind won't like that:
for(int i = 0; i < ALPHABETS; i++)
{
root = NULL;
...
1
vote
Accepted
Infinite looping
Well len can't possibly be in the same time both 15 and 16 and 13 (which is what your condition implies). Instead use
while ( len != 15 && len != 16 && len != 13);
Edit
Let's start ...
1
vote
Accepted
Pset4 recover problems detecting jpg data
It's not an infinite loop, it's just taking an extraordinarily long time to process. Look at your code to check for the signature:
for (int i = 0, n = sizeof(buffer); i < n; i++)
{
...
Only top scored, non community-wiki answers of a minimum length are eligible