I'm writing a function to reverse a string, but I keep on getting the error "Undefined symbols for architecture x86_64" when compiling (clang). Here is my code:
#include <iostream>
#include <string>
using namespace std;
char* reverse(string input);
int main() {
  char* output;
  output = reverse("abcd");
  cout << *output;
}
char* reverse(char* input) {
  char* reversed;
  reversed = new char(sizeof(input) - 1);
  for(int i = 0; i != '\0'; i++) {
    char* j = reversed + sizeof(input - 1);
    input[i] = *j;
    j++;
  }
  return reversed;
}
Specifically, this is what the compiler prints:
Undefined symbols for architecture x86_64:
  "reverse(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
      _main in test-c5860d.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [test] Error 1
I'm sure that there are also logic errors in my code, but I'd like to have it compile and run at least before I debug those. Thanks!
 
    