473,788 Members | 2,733 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

34 New Member
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 5392
manontheedge
175 New Member
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 New Member
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 New Member
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 New Member
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 New Member
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
1903
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 Tools\wce300\Pocket PC 2002\atl\include\atlbase.h(5395) : error C2664: '__WinCE_OutputDebugStringA' : cannot convert parameter 1 from 'const unsigned short *' to 'const char *' Types pointed to are unrelated; conversion requires reinterpret_cast,...
1
2560
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. ---------------------------- LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LPARAM lParamClient, HWND _hClient); ----------------------------
7
10267
by: Karthik | last post by:
Hello I am trying to convert the following??? The Code std::string* ChkName;
4
5718
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 project)***// //----dynapp.cpp----/ #include <windows.h #include "dynclass.h int main ( void
12
10091
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 it. here is the 4 errors. c:\C++\Ch15\Employee.h(29): error C2440: '=' : cannot convert from 'char ' to 'char '
3
16830
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 *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
2
3933
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 specialization #include <iostream> using namespace std; template <class T> class container {
9
2958
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
5129
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 path is: C:/Program Files/Microsoft Visual Studio 8/VC/include;C:/Program Files/Microsoft Visual Studio 8/VC/atlmfc/include;C:/Program Files/Microsof t Visual Studio 8/SDK/v2.0/include;C:/Program Files/Microsoft Visual Studio...
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10177
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10113
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8995
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5402
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2896
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.