Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

C++  cannot convert parameter 1 : Function Problem...  (urgent )

Posted on 2003-03-10
3
Medium Priority
?
295 Views
Last Modified: 2008-02-01
Hi
here is my code :

in my main() :

string TypeWord ;
 int plen ;
 cin >> TypeWord;
 plen = TypeWord.length();
 cout << plen;

if (VerifyWord(TypeWord,plen)) // here is my mistake
{
cout << TypeWord << " is in tree ";
}
else {
cout << TypeWord << "is not in tree." ;
}
               
here is my function VerifyWord :

bool VerifyWord(const char * word, int len)
{
  int plen;
  Dictio * n = root -> follow(word,len,plen);
  return (plen == len && n -> IsFullWord());
}          
     
here is my error :
'VerifyWord' : cannot convert parameter 1 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'const char *'

i know i wont convert cause its not the same but i cant make it work
i type a word and i check if its in my tree.
how can i make my CIN<< TypeWord ... word

need an answer
0
Comment
Question by:Italbro2
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
mnashadka earned 120 total points
ID: 8107476
Either change VerifyWord to look like:
bool VerifyWord(const std::string &word, int len)

or change the call to
if(VerifyWord(TypeWord.c_str(), plen))// c_str is the const char * conversion function
0
 

Author Comment

by:Italbro2
ID: 8108135
thk you
works good
0
 
LVL 8

Expert Comment

by:mnashadka
ID: 8108396
I'm glad I could help.
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question