clang testing.c -lcs50 -o testing
/tmp/testing-6c5209.o: In function `main':
testing.c:(.text+0x3f): undefined reference to `sort'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What am I doing wrong?
In C, you have to define/declare the functions before you use them
Ex0:
// function definition
void foo(void)
{
// some code
}
int main(void)
{
foo(); // call foo
}
Ex1:
// function declaration
void foo(void);
int main(void)
{
foo();
}
// function definition
void foo(void)
{
// some code
}
In EX1, you could define the function anywhere in the source code file. As long as it's declared before it is called, there should be no errors like this one. For more information, you may watch the short on functions!
Edit:
your need to compile the source code files together using a command like
clang testing.c helpers.c -lcs50 -o testing