1

I think I've finished find.c, but I'm not quite sure how to check it. For example, one of the things it must do is find 42 in {42, 43, 44}, so how do I enter this into the terminal window? Do I use generate and find, or just find? I've tried a few different ways that don't seem to be working.

1
  • You can use the check50... command mentioned on the pset3 page. It checks everything and gives you feedback.
    – user2477
    Commented Oct 17, 2014 at 7:06

1 Answer 1

0

You can test find by itself. generate is used to create a set of numbers to test with, to save you having to manually enter the numbers each time, and it is not required to test find.

find implements a specific input behaviour pattern. As long as you have not modified find.c in any way you should be able to pass the value you want to search for (the needle), on the command line, like so:

./find 42

find should then prompt you to start entering the list of numbers that you want to search in (the haystack). Enter each number at the prompt:

42enter 43enter 44enter

When you have entered the last number, hit CTRL+D to tell find to stop asking for numbers and start the search.

1
  • Thank you! I got it working and was able to test the program.
    – KJK
    Commented Aug 9, 2014 at 0:16

You must log in to answer this question.

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