473,394 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

error C2664: 'searchTree' : cannot convert parameter 2 from 'const char *' to 'char'

34
well the error i get is the title above:
error C2664: 'searchTree' : cannot convert parameter 2 from 'const char *' to 'char'

error is form this line
Expand|Select|Wrap|Line Numbers
  1. searchTree(treeObj->root ,data1.c_str());
  2.  
i have also attached searchTree below for yr reference
Expand|Select|Wrap|Line Numbers
  1. Tree<char> *treeObj = NULL;
  2. TreeNode<char> *treeNodeObj = NULL;
  3.  
  4. TreeNode<char>* searchTree(TreeNode<char> *cur, char nodeToAdd)
  5. {
  6.     if(cur == NULL) 
  7.     {
  8.         return NULL;
  9.     }
  10.     if(cur->IsSameNode(nodeToAdd))
  11.     {
  12.         return cur;
  13.     }
  14.     searchTree(cur->getLeft(), nodeToAdd);
  15.     searchTree(cur->getRight(), nodeToAdd);
  16. }
  17.  

could anyone help me with this problem..?
well at first i get the problem that it can convert from char to string.. thats y i added the .c_str() but now it gives me the new error above..
any help is appreciated..
I will check forum every 5 mins .. so i will reply quick..
Thanks in advance :)
Sep 5 '08 #1
5 5373
manontheedge
175 100+
what is 'data1' ? How did you declare it?

other than that, it LOOKS like you are attempting to make 'data1' into a string, and then pass it into a function looking for a char ... that's just not gonna happen ... why are you passing some sort of string into a char argument?
Sep 5 '08 #2
slizorn
34
oops my bad..
i declared it as string..

Expand|Select|Wrap|Line Numbers
  1. void handleOneLine(string string1)
  2. {
  3.     char * cstr, *p;
  4.     int counter;
  5.     string str (string1);
  6.     string data1, data2, data3;
  7.  
  8.     cstr = new char [str.size()+1];
  9.     strcpy (cstr, str.c_str());
  10.  
  11.     // cstr now contains a c-string copy of str
  12.  
  13.     int count = 0;
  14.     p=strtok (cstr,",");
  15.     count++;
  16.     while (p!=NULL)
  17.     {
  18.         p=strtok(NULL,",");
  19.         if( count == 1 )
  20.         {            
  21.             data1.append(p);
  22.             searchTree(treeObj->root ,data1.c_str());
  23.         }
  24.         else if( count == 2 )
  25.         {
  26.             data2.append(p);
  27. //            treeNodeObj->setLeft(data2);
  28.         }
  29.         else if( count == 3 )
  30.         {
  31.             data3.append(p);
  32. //            treeNodeObj->setRight(data3);
  33.         }
  34.         count++;
  35.         if( count == 3 )
  36.             break;
  37.     }
  38.  
  39.     delete[] cstr; 
  40. }
  41.  
Sep 5 '08 #3
manontheedge
175 100+
I edited my previous post, not sure if you saw ...

it looks like you are attempting to make 'data1' into a string, and then pass it into a function looking for a char ... that's just not gonna happen ... why are you passing some sort of string into a char argument?
Sep 5 '08 #4
slizorn
34
I edited my previous post, not sure if you saw ...

it looks like you are attempting to make 'data1' into a string, and then pass it into a function looking for a char ... that's just not gonna happen ... why are you passing some sort of string into a char argument?

oh yea.. haha i must be looking like a fool now...
err... so just use char variables from the start then yea?
done that.. that problem is solved.

thanks for yr help :)
Sep 5 '08 #5
manontheedge
175 100+
it happens, everybody does that kind of stuff
Sep 5 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ajay | last post by:
hi! I have a c++ file that does some XML processing (visual c++ using ATL). The file builds fine. However when i add the header #include<Python.h>, i get a number of errors C:\Windows CE...
1
by: mkarja | last post by:
Hi, I've been struggling with this error for a while and I don't know what's wrong. Any help would be appreciated. Here's code snippets and the error message. ----------------------------...
7
by: Karthik | last post by:
Hello I am trying to convert the following??? The Code std::string* ChkName;
4
by: Scott Chang | last post by:
Hi all I copied the following VC++ 6.0 code (written by someone in the website) to my VC++ .Net 2002-Windows XP Pro PC ////****Solution 'dyndllclass' (2 projects)***/// ///***dynapp****(1st...
12
by: GRoll35 | last post by:
I get 4 of those errors. in the same spot. I'll show my parent class, child class, and my driver. All that is suppose to happen is the user enters data and it uses parent/child class to display...
3
by: kaizen | last post by:
Hi, i wrote the code in C and compiled in VC++ compiler. at that time it has thrown the below mentioned error. error C2664: 'strcpy' : cannot convert parameter 2 from 'char' to 'const char *'...
2
by: Nick | last post by:
I'm learning C++ and ran into a compile error using Visual C++ 2005 Express on the following example program (located at http://www.cplusplus.com/doc/tutorial/templates.html): // template...
9
by: i | last post by:
#include<stdio.h> #include<conio.h> #include<process.h> #include<string.h> char ch; int n,m; void main(); char check(int,int,char); void cash(int,int,char); void debit_card(int,int,char);
1
by: misu101 | last post by:
Hi, I have a VS 6 project and I am trying to compile it using VS 2005. My program has the atlbase.h include which seems to trigger the errors. It used to compile OK using VS 6. The include...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.