Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Cannot convert from const char* to char*

Author
Message
z_man
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: Australia
Posted: 18th Mar 2008 14:40 Edited at: 18th Mar 2008 14:41
Ok, this is starting to get fustrating.



...returns an error:

error C2664: 'dbText' : cannot convert parameter 3 from 'const char *' to 'char *'

I've tried for a while now to get simple data types like strings working! First I was using c style strings, but they were annoying to organize, now I'm the std::string type and it's even more confusing.

Sorry if this query has an obvious answer, I am still getting to know C++.

z_man

EDIT: BTW, the inputData [ ] array is previously declared like so:
string inputData [ 100 ] ;

Intel Core 2 Duo 6600 2GB DDR2 RAM Radeon X1600 Series Realtek Sound System

Persist and you will succeed.
monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 18th Mar 2008 15:16
You need to explicitly cast it to a char*

i.e.

dbText ( xPos + 8 , yPos - 8 , (char*)textDisplay.c_str ( ) ) ;

Much good work is lost for the lack of a little more.
z_man
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: Australia
Posted: 19th Mar 2008 03:28
Thank you! That worked perfectly.

z_man

Intel Core 2 Duo 6600 2GB DDR2 RAM Radeon X1600 Series Realtek Sound System

Persist and you will succeed.
Abzero
16
Years of Service
User Offline
Joined: 22nd Mar 2008
Location:
Posted: 22nd Mar 2008 20:46
I hope that dbText does not modify the the (char *) value, otherwise bad things will happen.

This is a bad implementation of the parameters to dbText unfortunatly; as it should really be declared 'const.'
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 24th Mar 2008 20:02
I cheat... I make a char[whatever] and then pass the address

dbText(&MyChar).....

but everywhere else I do things much cleaner... I DONT use that routine much though.

Login to post a reply

Server time is: 2024-09-29 15:22:26
Your offset time is: 2024-09-29 15:22:26