please help me understand what I'm missing... why I don't have any random numbers when I enter : ./generate 10 | ./find 10 (well that the same result I have when I entered ./generate 1000 50 | ./find 127) here the results: `haystack[0] = haystack[1] = haystack[2] = haystack[3] = haystack[4] = haystack[5] = haystack[6] = haystack[7] = haystack[8] = haystack[9] = haystack[10] =

Didn't find needle in haystack.And when I enter this:$ ./find 42 50 43 ^d Didn't find needle in haystack.I have to enter myself number and finish by clt ^d ? haystack[0] = 50

haystack[1] = 42

haystack[2] =

Didn't find needle in haystack.` Why we have clt^d in the answer ? What's the meaning to print that data? Please tell me if you need to see my code, generate or search/sort. Thank you


When you run ./generate 10 | ./find 10, generate pipes numbers directly to find. Understand that find will print the prompts for numbers on the screen and will accept the numbers from generate directly, but the numbers will not be displayed. You could run generate by itself and see the numbers printed out. Also, if you want to have generate produce the same set of numbers each time, you need to add a seed number to the command. (See pset instructions.)

As for the execution of find, it only takes one number as the needle. The haystack numbers have to be entered one at a time as prompted. Ctrl-D tells the program that you are done entering numbers.

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

  • Thank for describing what I see. You mean that the random number doesn't print but it looks the value into it ? But I don't understand what I have to do next to have the same result asked : no print Haystack [] = but two numbers per line and than ctl^d. And why I don't have needle finded with the generate 1000 50 and find 127 : what do I have to do ?next ? – Genevie Jul 4 '17 at 1:56

You must log in to answer this question.

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