Click here to Skip to main content
15,888,113 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Implicit conversion from char * to string: g++ vs VS Pin
Stuart Dootson8-Sep-09 10:24
professionalStuart Dootson8-Sep-09 10:24 
QuestionVC++ MFC Strlen [modified] Pin
GC1048-Sep-09 4:09
GC1048-Sep-09 4:09 
QuestionRe: VC++ MFC Strlen Pin
David Crow8-Sep-09 4:39
David Crow8-Sep-09 4:39 
AnswerRe: VC++ MFC Strlen Pin
GC1048-Sep-09 4:52
GC1048-Sep-09 4:52 
AnswerRe: VC++ MFC Strlen Pin
Stuart Dootson8-Sep-09 4:51
professionalStuart Dootson8-Sep-09 4:51 
GeneralRe: VC++ MFC Strlen Pin
GC1048-Sep-09 4:59
GC1048-Sep-09 4:59 
GeneralRe: VC++ MFC Strlen Pin
Stuart Dootson8-Sep-09 5:17
professionalStuart Dootson8-Sep-09 5:17 
QuestionVC++ MFC class data member initialisation [modified] Pin
GC1048-Sep-09 1:59
GC1048-Sep-09 1:59 
I am learning to use VS2005 creating a VC++ MFC project to unterface to serial ports. I am in the initial stages of getting to grips with creating a serial port class. I am finding a few problems along the way with vartiable / data member initialisation.


CGCSerial h-file

int CharCount;
int CharCount2;
int CharCountThree;
CString TxString;
size_t InputStringLength;
TCHAR * pStr;
char * pOutputString;


cpp-file(s)

CMyDrawView::OnToolWrite2SerialPort
//member function called by clicking on windows menu item
{
CGCSerial *pGcSp = new CGCSerial(_T("12345")); //create instance of CGCSerial class
pGcSp -> GCTx; //call transmit member function
delete pGcSp; //cleanup
}


CGCSerial::GCSerial(TxString)
{
//constructor
CharCount2 = 0
CharCountThree = 0;
}

CGCSerial::~GCSerial
{
//destructor
}

CGCSerial::GCTx
{
InputStringLength = wcslen(TxString); //measuring length of incoming string
CharCountThree = sizeof(InputStringLength); //load CharCount3 with something
TempString.Format(_T("executing function CGCSerial::GCTx"));
AfxMessageBox(TempString);

pStr = TxString.GetBuffer(256);
CharCount2 = sizeof(pStr);
TxString.ReleaseBuffer;

InputStringLength = wcslen(pStr); //measuring length of

CharCount2 = 0x2345; // ###
CharCountThree = 0x5678; //###

CharCount2 = sizeof(TxString);
CharCountThree = sizeof(pOutputString);

pOutputString = CW2A(TxString); //convert wide string to ANSI string
...
...

}


My problem is that I admit this code doesn't look the most useful and is due to getting to grips with VC++ functions. The lines marked with ### don't seem to get executed! If I use the debugger, the debugger stops at these lines but upon viewing these data member's they do not get loaded with 0x2345 & 0x5678 respectively??? Is this a compiler bug??

any help would be greatly appreciated Smile | :)

modified on Tuesday, September 8, 2009 8:21 AM

AnswerRe: VC++ MFC class data member initialisation Pin
CPallini8-Sep-09 2:10
mveCPallini8-Sep-09 2:10 
AnswerRe: VC++ MFC class data member initialisation Pin
Code-o-mat8-Sep-09 3:50
Code-o-mat8-Sep-09 3:50 
GeneralRe: VC++ MFC class data member initialisation Pin
GC1048-Sep-09 4:00
GC1048-Sep-09 4:00 
Questionwhich module creates a specific file? Pin
Joseph Marzbani8-Sep-09 1:25
Joseph Marzbani8-Sep-09 1:25 
AnswerRe: which module creates a specific file? Pin
Garth J Lancaster8-Sep-09 1:52
professionalGarth J Lancaster8-Sep-09 1:52 
GeneralRe: which module creates a specific file? Pin
Joseph Marzbani8-Sep-09 3:00
Joseph Marzbani8-Sep-09 3:00 
AnswerRe: which module creates a specific file? Pin
Selvam R8-Sep-09 2:02
professionalSelvam R8-Sep-09 2:02 
AnswerRe: which module creates a specific file? Pin
Stuart Dootson8-Sep-09 3:39
professionalStuart Dootson8-Sep-09 3:39 
AnswerRe: which module creates a specific file? Pin
kilt10-Sep-09 6:36
kilt10-Sep-09 6:36 
QuestionRe: which module creates a specific file? Pin
David Crow14-Sep-09 3:50
David Crow14-Sep-09 3:50 
QuestionVC++ pointers with Readfile function [modified] Pin
GC1048-Sep-09 1:19
GC1048-Sep-09 1:19 
AnswerRe: VC++ pointers with Readfile function Pin
«_Superman_»8-Sep-09 1:27
professional«_Superman_»8-Sep-09 1:27 
GeneralRe: VC++ pointers with Readfile function Pin
Cedric Moonen8-Sep-09 3:26
Cedric Moonen8-Sep-09 3:26 
AnswerRe: VC++ pointers with Readfile function Pin
David Crow8-Sep-09 3:05
David Crow8-Sep-09 3:05 
GeneralRe: VC++ pointers with Readfile function Pin
GC1048-Sep-09 4:48
GC1048-Sep-09 4:48 
GeneralRe: VC++ pointers with Readfile function Pin
David Crow8-Sep-09 4:56
David Crow8-Sep-09 4:56 
GeneralRe: VC++ pointers with Readfile function Pin
GC1048-Sep-09 5:06
GC1048-Sep-09 5:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.