0

I have thiscode:

/**
 * helpers.c
 *
 * Computer Science 50
 * Problem Set 3
 *
 * Helper functions for Problem Set 3.
 */

#include <cs50.h>

#include "helpers.h"

/**
 * Returns true if value is in array of n values, else false.
 */
bool search(int value, int values[], int n)
{
   if(n<=0){
       return false;
   }
    for (int i=0; i<n; i++){   //n is size of array
        if(value == values[i]){
        return true;
        }

    }
    return false;
}

/**
 * Sorts array of n values.
 */
void sort(int values[], int n)
{
    // TODO: implement an O(n^2) sorting algorithm
    return;
}

it compiles but for some reason it outputs all this stuff at the end

https://i.sstatic.net/xG3p9.png

What does this refer to?

1 Answer 1

1

It means that you tried to make helpers when you should have done make find. Part of this lesson is to understand how to create an executable from multiple source code files. Since helpers.c has no main() in it, the compiler is spitting out these errors.

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

2
  • I figured it might've been something due to lack of main but wasn't sure. Does this mean I don't compile either header.c or header.h? Also, what's the purpose of having a header.c and a header.h file, isn't that horribly redundant, shouldn't you just need header.h only? Commented Aug 23, 2016 at 19:01
  • there is no header.c or header.h file. There is a helpers.c and helpers.h. These will be used along with find.c an find.h. As for the reason for a .c file (contains code), and a .h file (contains various definitions and other information needed to compile), I would refer you back to class lectures and materials on the subject.
    – Cliff B
    Commented Aug 23, 2016 at 19:11

You must log in to answer this question.

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