473,320 Members | 2,048 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,320 software developers and data experts.

error C2440: '=' : cannot convert from 'char *' to 'char'

34
error is as stated in the topic above:
error C2440: '=' : cannot convert from 'char *' to 'char'

code is below
Expand|Select|Wrap|Line Numbers
  1. void handleOneLine(string string1)
  2. {
  3.     char * cstr, *p;
  4.     int counter;
  5.     string str (string1);
  6.     char 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 = p;
  22.             searchTree(treeObj->root ,data1);
  23.         }
  24.         else if( count == 2 )
  25.         {
  26.             data2 = p;
  27. //            treeNodeObj->setLeft(data2);
  28.         }
  29.         else if( count == 3 )
  30.         {
  31.             data3 = p;
  32. //            treeNodeObj->setRight(data3);
  33.         }
  34.         count++;
  35.         if( count == 3 )
  36.             break;
  37.     }
  38.  
  39.     delete[] cstr; 
  40. }
  41.  
the error is below:
Expand|Select|Wrap|Line Numbers
  1. error C2440: '=' : cannot convert from 'char *' to 'char'
  2. 1>        There is no context in which this conversion is possible
  3.  
and the lines from which the errors are caused are:
Expand|Select|Wrap|Line Numbers
  1. data1 = p;
  2. data2 = p;
  3. data3 = p;
  4.  

how can i solve this problem?
i will check the forum every 5 mins so plz do check back if u have posted a qn for me..
thanks in advance :)
Sep 5 '08 #1
2 20364
JosAH
11,448 Expert 8TB
Well, data1, data2 and data3 are just chars and p is a pointer to a char. You
cannot implicitly convert one to the other (as your error diagnostic message showed).
Probably you mean "data1= *p" etc.

kind regards,

Jos
Sep 5 '08 #2
slizorn
34
Well, data1, data2 and data3 are just chars and p is a pointer to a char. You
cannot implicitly convert one to the other (as your error diagnostic message showed).
Probably you mean "data1= *p" etc.

kind regards,

Jos
yup u r right :D
thanks ever so much :)
Sep 5 '08 #3

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

Similar topics

0
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug...
2
by: Abhijit Bhadra | last post by:
Hi , I was trying to build my project in VC with latest Service Packs but got this error . C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(125) : error C2440: 'return' :...
3
by: Peter | last post by:
Hi, I am trying to compile an existing project (originally c) in .NET (rename .c files to .cpp). After fixing some problems, here are the ones that I don't know how to deal with:...
1
by: mn04 | last post by:
I am getting the following error message during compilation of my C++ program on XP laptop using .NET libraries: ossxerces_utils.cxx...
2
by: Ketil B | last post by:
Hi All Im geting the compiler error error C2440: '=' : cannot convert from 'short (__thiscall CMSComm::*)(void)' to 'short on this line sCommEvent = m_ctlMSComm.GetCommEvent
2
by: Qiao Yun | last post by:
I used vc++.net (visual studio .net ) to open a project which can work well in vc++6.0. I succeeded in compiling the project in vc++.net in release mode . But when I tried to compile the project...
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...
2
by: teddybyte | last post by:
my script below is: #include "stdafx.h" int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, ...
5
by: wong_powah | last post by:
#include <vector> #include <iostream> using std::cout; using std::vector; enum {DATASIZE = 20}; typedef unsigned char data_t;
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.