0

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

6
Contributors
5
Replies
6
Views
10 Years
Discussion Span
Last Post by anw
0

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.

0

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

0

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 topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.