Skip to main content
added 1 character in body
Source Link

What is the rationale for the header files in headerhelpers.c? For example there is cs50.h but not stdio.h even though the functions are all stdio except for bool which is in neither CS50 nor helpers. And why include header.h, when the functions are written there in the file.

#include "cs50.c"
#include "helpers.c"       

/**
* Returns true if value is in array of n values, else false.
*/
bool search(int value, int values[], int n)
{

Thank you for your help!

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 except for bool which is in neither CS50 nor helpers. And why include header.h, when the functions are written there in the file.

#include "cs50.c"
#include "helpers.c"       

/**
* Returns true if value is in array of n values, else false.
*/
bool search(int value, int values[], int n)
{

Thank you for your help!

What is the rationale for the header files in helpers.c? For example there is cs50.h but not stdio.h even though the functions are all stdio except for bool which is in neither CS50 nor helpers. And why include header.h, when the functions are written there in the file.

#include "cs50.c"
#include "helpers.c"       

/**
* Returns true if value is in array of n values, else false.
*/
bool search(int value, int values[], int n)
{

Thank you for your help!

splitting multiple questions up into separate posts
Source Link

Header files, debugger, and calling pset 3 in helpers pset3

Just a couple of questions that don't seem to be already answered inWhat is the forum.

  1. 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.

  2. 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.

  3. 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) {
  1. 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!

Header files, debugger, and calling pset 3

Just a couple of questions that don't seem to be already answered in the forum.

  1. 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.

  2. 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.

  3. 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 in the haystack loop, with no way to exit before the 65536 iteration except Control D which exits GDB completely!

(gdb) run 23
Starting program: /home/jharvard/Dropbox/pset3/find/find 23

Breakpoint 1, main (argc=2, argv=0xbffff0b4) at find.c:27
27      if (argc != 2)
(gdb) next
34      int needle = atoi(argv[1]);
(gdb) 
  1. 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!

Header files in helpers pset3

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 except for bool which is in neither CS50 nor helpers. And why include header.h, when the functions are written there in the file.

#include "cs50.c"
#include "helpers.c"       

/**
* Returns true if value is in array of n values, else false.
*/
bool search(int value, int values[], int n)
{

Thank you for your help!

Source Link

Header files, debugger, and calling pset 3

Just a couple of questions that don't seem to be already answered in the forum.

  1. 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.

  2. 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.

  3. 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 in the haystack loop, with no way to exit before the 65536 iteration except Control D which exits GDB completely!

(gdb) run 23
Starting program: /home/jharvard/Dropbox/pset3/find/find 23

Breakpoint 1, main (argc=2, argv=0xbffff0b4) at find.c:27
27      if (argc != 2)
(gdb) next
34      int needle = atoi(argv[1]);
(gdb) 
  1. 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!