Just a couple of questions that don't seem to be already answered inWhat is the forum.
When the Generate text file with random numbers get piped into find.c how does it know which command line function to place the text into? For example, I tried to test to see if I could pipe text into the main (argc) command line, but it didn't work. My guess it that it just automatically find the 2nd command line argument, (the first non main function which is the GetInt on line 43) and then keeps inputing an integer until all the generate integers are used up.
On a similar note how does the program know to stop after say 1000 numbers have been generated? Based on the code it should stop looping once MAX number has been reach. Manually we had to click on Control D to stop the program. Even when more than MAX numbers are generated in Generate.c for example ./generate 65537 the program still seems works.
talking about control D. I don't seem to be able to get out of the haystack loop when I use the gdb debugger. My debugging commands are,
gdb ./find
break main
run 10
next
and I then eventually get stuck inrationale for the haystack loop, with no way to exit beforeheader files in header.c? For example there is cs50.h but not stdio.h even though the 65536 iterationfunctions are all stdio except Control Dfor bool which exits GDB completely!is in neither CS50 nor helpers. And why include header.h, when the functions are written there in the file.
(gdb) run#include 23"cs50.c"
Starting program:#include /home/jharvard/Dropbox/pset3/find/find"helpers.c" 23
Breakpoint 1, main (argc=2, argv=0xbffff0b4) at find.c:27
27
/**
* Returns true if value ifis (argcin !=array 2)
(gdb)of next
34n values, else false.
*/
bool search(int value, int needlevalues[], =int atoi(argv[1]n);
(gdb) {
- Lastly what is the rationale for the header files in header.c? For example there is cs50.h but not stdio.h even though the functions are all stdio. And why include header.h, when the functions are written there in the file.
Thank you for your help!