My error : Undefined first referenced
symbol in file
main /usr/sfw/lib/gcc/sparc-sun-solaris2.10/3.4.3/crt1.o
ld: fatal: symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
This program prompts the user to enter a word, phrase, or sentence and determines whether the input string is a palindrome or not.
#include<vector>
#include <iostream>
#include <iomanip>
#include <string>
usingnamespace std;
void toUpper(string & str, string & str1);
void removeNonAlphabets(string & str, string & str1);
bool isPalindrome(string &obj);
int main()
{
string str, upperstr, alphastr;
cout<< "Enter input to see if it is a palindrome" << endl;
getline(cin, str);
cout<<"original input str contains" <<endl;
cout<<" "<< str <<endl;
toUpper(str, upperstr);
cout<<"after conversion to uppercase,input str becomes:"<<endl;
cout<<" "<<upperstr<<endl;
if(isPalindrome(alphastr))
cout<<endl<<alphastr<<" is a palindrome!"<<endl;
else
cout<<endl<<alphastr<<" is not a palindrome!"<<endl;
cout<<endl;
return 0;
}
void toUpper(string &str, string & upperstr)
{
int s = str.length();
for(int i=0;i<s;i++)
upperstr.push_back(toupper(str[i]));
}
void removeNonAlphabets(string &str, string &alphastr)
{
int s=str.length();
for(int i =0;i<s;i++)
if(isalpha(str[i]))
alphastr.push_back(str[i]);
}
bool isPalindrome(string &str)
{
int s = str.length();
for(int i=0;i<s/2;i++)
if(str[i]!=str[s-i-1])
returnfalse;
returntrue;
}
why does this keep coming up "Undefined first referenced
symbol in file
main /usr/sfw/lib/gcc/sparc-sun-solaris2.10/3.4.3/crt1.o
ld: fatal: symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status"
Hey, when I run in cpp 4.9 compiler, it runs fine.
However, when I fill in AGTT for example, (which is obviously not a palindrome), it says its a palindrome:P