0

I'm in pset3 and have already written the code and it compiled successfully. However when running find.c and providing the values, Ctrl+d won't work. I get no response or feedback whatsoever so I just press Ctrl+c to quit.

There was a question here mentioning the same thing and people told him that he must have changed something in the find.c file. So I deleted everything, redownloaded the zip file, extracted it and put the code back in helpers.c and made sure not to touch find.c or change anything else and still I got the same problem!

Any ideas?

1 Answer 1

1

Are you sure that you are correctly interpreting what is happening? It sounds to me like the ctrl-d may well be working just fine, but the code is going into an infinite loop at some later point, but before printing anything else out. Remember, there are very few printf() statements between requesting the list of numbers and the end of the program. Both sort and search routines can easily have an infinite loop if there is a bug. (I'm betting that the infinite loop is in the binary search.)

You might try temporarily adding a printf() statement at the beginning of both the sort() and search() functions just to say that they are starting. At the very least, it will tell you if you are actually calling and starting each of those functions. If one of them is going into an infinite loop, the printf() statements will give you a clue where this is happening.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

1
  • You were absolutely right. There was indeed an infinite loop in my sorting function (counter never reached 0). Thanks a lot :)
    – Ahmed
    Jan 13, 2016 at 17:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .