Solved

converting DDX_TEXT data to char[]

Posted on 2004-04-09
14
441 Views
Last Modified: 2013-11-20
Hello all,

I have a Dialog that accepts data into a variable m_myvar.  I need to feed this to a function that is expecting a char[]  Is there any way to convert the data from a DDX_TEXT box to char[].  I don't want to change the whole function.

DDX_TEXT(pDX, IDC_EDIT1, m_myvar);

I need m_myvar to be turned to  a char[].

Thanks!
0
Comment
Question by:bluedragon99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 5
14 Comments
 
LVL 1

Author Comment

by:bluedragon99
ID: 10794548
CString to char * would work for me too....HELP!!
0
 
LVL 4

Expert Comment

by:bkfirebird
ID: 10794554
Hi,

What is the datatype of m_myvar ? If it is a CString, then you can simply type cast it.

-Kiran Adigopula
0
 
LVL 1

Author Comment

by:bluedragon99
ID: 10794584
I can use anything DDX_TEXT accepts for an edit box.  CString would work I belive.  I am really new to c++, how would I convert a cstring to char?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Accepted Solution

by:
bkfirebird earned 500 total points
ID: 10794593
try (LPSTR) m_myvar
or (LPSTR)(LPCTSTR) m_myvar

0
 
LVL 1

Author Comment

by:bluedragon99
ID: 10794622
will a function expecting a char accept an lpstr, again I am pretty much a newbie to c++.  Where would I use this right before the function call to convert the type to what it is expecting?
0
 
LVL 1

Author Comment

by:bluedragon99
ID: 10794634
How and where would I go about defining the DDX_TEXT var?
0
 
LVL 4

Expert Comment

by:bkfirebird
ID: 10794657
you can declare the variable in your class variables ...

class myclass
{
public :
CString m_myvar;
....................
};

if you have a function which takes a character array as input ....
void printstr (char * str)
{
   printf("\ntest %s", str);
}

you can call it as .....
printstr ((LPSTR)(LPCSTR)m_myvar);

hope this helps
0
 
LVL 1

Author Comment

by:bluedragon99
ID: 10794726
ok m_Data is declared as a global CString now.

function call looks like this now

send(.........other stuff here.....................................m_data,strlen(m_data))

function looks like:

BOOL CUDPSocket::Send(int iSourcePort,LPCSTR lpDestinationAddress,int iDestinationPort, char* buf,int BufLength)


I am completly lost here, sorry for being such a pain but I have been working on a solution for this for DAYS with no luck...:(
0
 
LVL 1

Author Comment

by:bluedragon99
ID: 10794739
arrrrrrrrrrgggggggggggggg m_data keeps coming up UNDECLARED when it declared in the friggen header file as extern?!?!???!??
0
 
LVL 4

Expert Comment

by:bkfirebird
ID: 10794743
call the function like this ...

send(.........other stuff here...................................., (LPSTR)(LPCSTR)m_data,m_data.GetLength())
0
 
LVL 1

Author Comment

by:bluedragon99
ID: 10794749
oops sorry had m_data instead of m_Data, still don't know how to correct this though..

ok m_Data is declared as a global CString now.

function call looks like this now

send(.........other stuff here.....................................m_data,strlen(m_data))

function looks like:

BOOL CUDPSocket::Send(int iSourcePort,LPCSTR lpDestinationAddress,int iDestinationPort, char* buf,int BufLength)
0
 
LVL 1

Author Comment

by:bluedragon99
ID: 10794782
will m_data.GetLength() work without any changes to the current function:


int BufLength
0
 
LVL 4

Expert Comment

by:bkfirebird
ID: 10794797
yes, it should work fine
0
 
LVL 1

Author Comment

by:bluedragon99
ID: 10794882
You know your stuff man it worked like a charm!  THANKS!!!!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
matchUp  challenge 6 82
ShiftLeft challenge 21 95
abstract class with all non abstract mentods 6 87
Can not remove SSL certificate on iPhone 6 - iOS10.2 12 1,687
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question