C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 28th, 2009, 01:46 AM
llschrad llschrad is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 9 llschrad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 4 m 7 sec
Reputation Power: 0
Syntax errors - Error C2568 'indentifier': unable to resolve function overload

I am having a hard time understanding how to pass arguments to a function. I have errors on all of my function call arguments. It seems like it should be fairly straight forward but it's not. Here is my program. I am basically trying to pass a userstring and list of vowels, then count vowels, consonants or both. I apprecaite any suggestions.

//Function prototypes
int countVowels(char *, char[]);
int countConsonant(char *, char[]);
int countCharacters(char *, char[]);
char input[];
char *strPtr;

int main()
{


char choice;
int length;
length = strlen(input);
char vowels[] = {'a'||'A', 'e'||'E', 'i'||'I', 'o'||'O', 'u'||'U'};



//***********************************************
// Get string from user. *
//***********************************************

cout << "Enter a string. ";
cin.getline(input, length);

//**************************************************
//Display menu. *
//**************************************************
do
{
cout << "A) Count the number of vowels in string \n";
cout << "B) Count the number of consonants in string \n";
cout << "C) Count both vowels and consonants in string \n";
cout << "D) Enter another string \n";
cout << "E) Exit the program \n";
cin >> choice;



//**************************************************
//Respond to user's choice. *
//**************************************************

switch (choice)
{
case 'A':
case 'a':

cout << "Your string has " << countVowels (input, vowels) << " vowels."; endl;
break;

case 'B':
case 'b':

cout << "Your string has " << countConsonant (input, vowels) << " consonants."; endl;
break;

case 'C':
case 'c':

cout << "Your string has " << countCharacters (input, vowels) << " characters."; endl;
break;

}

} while (choice != 'E'||'e');

return 0;
}
//************************************************** **
// Count vowels. *
//************************************************** **

int countVowels(char *strPtr, char vowels)
{
int vowCount = 0; // Vowel total

while (*strPtr != '\0')
{
if (*strPtr == vowels)
vowCount++;
strPtr++;
}
return vowCount;
}


//************************************************** **
// Count Consonants. *
//************************************************** **

int countConsonant(char *strPtr, char vowels)
{
int conCount = 0; // Consonant total

while (*strPtr != '\0')
{
if (*strPtr != vowels)
conCount++;
strPtr++;
}
return conCount;

}
//************************************************** *
// Count Characters *
//************************************************** *
int countCharacters (char *strPtr, char vowels)

{
int charCount = 0; // Character total

while (*strPtr != '\0')
{
charCount++;
strPtr++;
}
return charCount;

}

Reply With Quote
  #2  
Old July 1st, 2009, 03:20 PM
larssss larssss is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2009
Posts: 30 larssss User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 54 m 18 sec
Reputation Power: 1
Cool hehe

you can not have call a function in the argument of a function...

Reply With Quote
  #3  
Old July 5th, 2009, 11:52 AM
MaHuJa MaHuJa is offline
Contributing User
Click here for more information.
 
Join Date: Dec 2007
Posts: 851 MaHuJa User rank is Private First Class (20 - 50 Reputation Level)MaHuJa User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 6 Days 15 h 29 m 24 sec
Reputation Power: 2
Send a message via Skype to MaHuJa Send a message via XFire to MaHuJa
larssss:
Your reply is bull**** no matter which way I read it.

llschrad:
Your program has plenty problems in it.
The first and most obvious would be easily solved by using the standard library string instead of a mishmash of char* and char[].

char input[]; // How long? Might turn this into a char* pointing to anywhere.
int length = strlen(input); // The length of... what? Does not do what you expect in either case.

The reason you get that particular error message may be related to that
int countVowels(char *strPtr, char vowels) definition below
which takes another set of parameters, and the compiler does not know which one to pick.

Note that your way of finding these vowels in the string fails...
char vowels[] = {'a'||'A', 'e'||'E', 'i'||'I', 'o'||'O', 'u'||'U'};
'a'||'A' resolves to the boolean value true, which when converted to an 8bit int (that is, char) is typically 1. (May vary with compiler)
In other words, you're really writing char vowels[] = {1,1,1,1,1};
Use const char* vowels = "aAeEiIoOuU" instead.

And when you do the comparison to a single char in the defined function... you'd only be checking for that particular one anyway.



If you really really cannot use std::string, do this:
const int maxlen = 64; // Must have a value...
char input[maxlen];

and use that maxlen rather than your erronous length measurement.
Also, use all char* in your function parameters, unless you have a number in them.
When you pass a char[] to anywhere requiring a char* you might want to use &name[0] if the compiler complains.
__________________
Quote:
Programming by Coincidence
Fred types in some more code, tries it, and it still seems to work. [Then] the program suddenly stops working. [...] Fred doesn’t know why the code is failing because he didn’t know why it worked in the first place.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Syntax errors - Error C2568 'indentifier': unable to resolve function overload


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
Stay green...Green IT