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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CString to char*

Status
Not open for further replies.

Jaredino

Technical User
Jan 31, 2006
17
GB
Hi,
I have read lots of posts on this but still can't come up with any answers. I have a CString named 'm_sResults1' that needs to be passed to a function named 'openWavFile()' that expects a char*. How do I convert a CString to a char*??
 
IIR right, chars can be either bytes or fixed length strings. I think the * means that it's a pointer?
When dimming CString do it in the format
dim Cstring as string * 8
Making it an 8 character fixed length as an example. I can't say exactly how long that string should be though.
 
Pass by reference.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Thanks for your quick replies but I'm new to programming so unfortunately I don't know what either 'dimming' or 'passing by reference' is! Is there not just a line of code that can assign a CString object to whatever the pointer is pointing at?
 
Did you write a declaration for this function openWavFile ??? Or is it part of a COM object that you are using? ... how are you going to call it?
 
Yes, the declaration for the function is:

void CWavFile::eek:penWavFile(char* fileName)

The function is called within CWavFile.cpp file
The member variable m_sResults is in a different class
 
Ooops sorry
Ignore me
I'll go try the right one should I?
Thanks anyway!
 
Doh! I thought he was just trying to declare a C API function in VB too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top