Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems passing string. Can't Convert wchar_t error. 1

Status
Not open for further replies.

ColdPhreze

Programmer
Apr 15, 2002
93
Hi, and thanks in advance for any help.

I am trying to pass a string (I've tried everything I can think of) to a component I've added to BCB 6. The component was built in Delphi and the variables it receives are defined as WideString. You can find the source for the component at It is for editing the tags of video files. The website is here:

I call the function, and always get the errors:
E2034: Cannot convert 'wchar_t *' to 'wchar_t * *'
E2342: Type mismatch in parameter 'filename' (wanted 'wchar_t * *', got 'wchar *')


Here is the code I have now (The ReadAVITags function receives a lot of wchar_t vars, I've condensed it to just this one to save space) :

wchar_t * filename = new wchar_t[100];
//the following reads the tags from an AVI file and is the ActiveX Component I added to BCB.
EAVITagsGenerator->ReadAVITags(filename);


Please answer the following questions, and number you answers to correspond with the questions, thx.
1) What does it mean when there are 2 *s (wchar_t * *)?
2) How do I make/redefine my 'wchar_t * filename' to conform to 'wchar_t * *'?
3) What is an easy way, once I get the declaration correct, to convert the contents to an AnsiString?
4) Where (preferrably on the web) can I find a definitive guide to the differences of all the string types in BCB?

Thanks so much for your assistance,
KyferEz

Check out my DeVry Senior Project
 
> 1) What does it mean when there are 2 *s (wchar_t * *)?

It means a pointer to a pointer.

filename is a variable that stores a pointer (address where the wchar_t data resides). 'filename' itself also has a memory address, it is this memory address that you need to pass to the function. (&filename), hence a pointer to a pointer.

Usually a function will require the address of a pointer if it is going to modify the pointer (like allocate the space within the function). You may want to look at the function EAVITagsGenerator and make sure that it isn't allocating the space for filename. If so, you have a memory leak because you've lost the pointer to the space you allocate and hence can never free it.

> 2) How do I make/redefine my 'wchar_t * filename' to conform to 'wchar_t * *'?

You pass the address of 'filename' to the function just like you would pass any variable by address:

Code:
EAVITagsGenerator->ReadAVITags(&filename);

> 3) What is an easy way, once I get the declaration correct, to convert the contents to an AnsiString?

The AnsiString constructor will convert it for you if you assign it like this:
Code:
 AnsiString filenameA = filename [code];

or you can do:

[code]AnsiString filenameA;

filenameA = AnsiString(filename);

> 4) Where (preferrably on the web) can I find a definitive guide to the differences of all the string types in BCB?

C++ builder Help should give you what you need. If you need something from the web, try googling. I just did a quick search for "c++ builder" "string types" and found:


Which looks like a good starting point.

Hope some of this helps.

Good Luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top