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

Split into a new thread. Please don't post unrelated questions into existing threads.

Member Avatar for iamthwee

What's the error msg?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.