Hi,

Is there someone out there who can help. I've written some simple functions, on the same page as the main code:

bool IsAVowel (char ch)
{
      if(ch=='a')|| (ch=='e') || (ch=='i') || (ch=='o') || (ch==''u)
      {
      return true;
      }
      return false;
}

The compiler message gives 'linker error'
Why won't the main program use these. Sorry if this is a bit basic, but could really use some help with this.

jenco

Hi,

Is there someone out there who can help. I've written some simple functions, on the same page as the main code:

bool IsAVowel (char ch)
{
      if(ch=='a')|| (ch=='e') || (ch=='i') || (ch=='o') || (ch==''u)
      {
      return true;
      }
      return false;
}

The compiler message gives 'linker error'
Why won't the main program use these. Sorry if this is a bit basic, but could really use some help with this.

jenco

i am not sure ,
but why can not the if statement be like this :

if(ch=='a'|| ch=='e' || ch=='i' || ch=='o' || ch==''u)

try to run it and see.

Did you define the function like this: bool IsAVowel (char) before calling main? Not doing this will result in a linker error (something like: could not find function definition). Your program should look something like this:

#include <blabla>
 
bool IsAVowel (char);
 
int main(void)
{
-code-
}
 
 bool IsAVowel (char ch)
{      
if (ch=='a')|| (ch=='e') || (ch=='i') || (ch=='o') || (ch==''u)      
{
      return true;  
 
}     
 return false;
}

Niek

I think you either didn't post the real code, or your compiler is giving bogus error messages. Before going any further, I would fix the syntax error in this line:

if (ch=='a')|| (ch=='e') || (ch=='i') || (ch=='o') || (ch==''u)

If (ch==''u) compiles at all, it most certainly won't do what you intend.

Regards,
anw

This article has been dead for over six months. Start a new discussion instead.