Function to Reverse a string
Hey guys im looking for some more insite on another problem my teacher gave me. I was tasked with creating a function that reverses a string. This is what ive come up with and it worked as a stand alone program but once i converted it to a function I keep getting an error when I compile it saying.
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
Code:
string Reverse(string original)
{
//decare and assign variables
int strlen=original.length();
string s=original, output="";
//Loop to reverse letters. sloppy but it works.
for(int i=0,ii=(strlen-1); i<=strlen; i)
{
output[ii]=original[i];
i++;
ii--;
}
return(output);
}
Tested further and the error is somewhere else in the code. Disregard
Any help is greatly appreciated. and I apologize for the sloppy coding I was in a bit of a rush. Thank you as always.