Programs find.c and generate.c work properly when ran standalone. And find.c also passes the check50. however when trying to combine generate and find as in ./generate x x | ./find x the program starts but gets stuck while sorting the numbers. Does anybody have an idea how that is possible?
-
By "stuck" do you mean an infinite loop ?– QuevunCommented Mar 1, 2015 at 7:55
-
No not really, it just stops processing i guess. When running stand alone and printing the sorting process everything works fine. However, when combining with generate the sorting loop just pauzes in the middle of printing one of the numbers. (ie. it shows 10 20 30 4 followed by a blinking cursor).– MihalyCommented Mar 1, 2015 at 12:47
-
More interestingly, it works fine if a search a 5 digit number, but otherwise it gets stuck. so using ./generate 5 2 | ./find 20312 works, but ./generate 5 2 | ./find 2012 doesn't– MihalyCommented Mar 1, 2015 at 12:58
-
Can you post your code for helpers.c ?– QuevunCommented Mar 1, 2015 at 13:29
-
gist.github.com/anonymous/ae432b578f3dae049c98– MihalyCommented Mar 1, 2015 at 15:19
Add a comment
|
1 Answer
Your program is indeed stuck in an infinite loop, using the condition middle!=upper
is not a good idea since middle
may never be equal to upper
in your program.