Nov 1, 2015 at 6:23pm UTC
how can i convert from string to char*?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
string *strreaded=NULL;
char *chrreaded=NULL;
//on window procedure:
//..................
consolewindow *richedit = (consolewindow *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (uMsg)
{
case WM_KEYDOWN:
{
if ((wParam==VK_RETURN) && (richedit->blnread==true ))
{
richedit->blnread=false ;
if (richedit->is_number(*richedit->strreaded)==true )
*richedit->dblreaded=atof(richedit->strreaded->c_str());
else
*richedit->dblreaded=0;
strcpy(richedit->chrreaded,richedit->strreaded->c_str());
}
//................
//my read function:
void read(char &txttext)//corrigir
{
blnread=true ;
chrreaded=&txttext;//string
}
seems that i lose the adress or something.
can anyone advice me?
Last edited on Nov 1, 2015 at 6:34pm UTC
Nov 2, 2015 at 8:52am UTC
What are you trying to do?
The read(...) function isn't called anywhere?
Nov 3, 2015 at 11:53am UTC
It all looks very confused.
You cannot use strtok(...) with a string like "hello" because it is a literal and therefore const. Use
char intnumber[] ="hello" ;
instead.
Nov 3, 2015 at 6:57pm UTC
i need seend the intnumber adress with cw.read(). for i read something that will be changed on intnumber(sorry the variable name.. i'm testing)
Nov 4, 2015 at 8:16pm UTC
because the OS(the Windows 7 tell me(when it's executed): 'the program stops to responding' and then close it after click on 'cancel' button.
Nov 5, 2015 at 11:43am UTC
Yes, that's a crash. But from the code you provide I cannot see what the problem is.
Check all of you your pointers whether they are valid.
Is richedit
valid? richedit->strreaded
? Etc.
Nov 5, 2015 at 7:39pm UTC
yes. you both have right.
my problem is that i lose the pointer :(
(i had printed the values.. and they are converted. but not on right variable :( )
i'm sorry been off-topic: but how can i get a char* pointer on function parameter?