Solved

converting DDX_TEXT data to char[]

Posted on 2004-04-09
14
431 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
  • 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 82
only14 challenge 19 63
fizzArray2 challenge 1 56
Path of Workbook 3 45
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This video discusses moving either the default database or any database to a new volume.

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now