Re: setting an instance of an object
- From: Alex Blekhman <xfkt@xxxxxxxxx>
- Date: Mon, 11 Jun 2007 17:57:41 +0300
Stephanie Doherty wrote:
[...] It is now giving me the same error message, but it is coming in a later assignment for that same structure. The exact code is:
lpPweParam.lLengthFldr = wcslen(lpPweParam.lptstrFolder);
I had abbreviated the structure declaration in my original message, but the lLengthFldr and lptstrFolder members are in the original structure declaration. (The lptstrFolder member is assigned in an previous line of code without a problem.)
So it seems that you make the same error: you access uninitialized memory by a pointer. Before you can access a content pointed by `lpPweParam.lptstrFolder' member you must ensure that it points to allocated chunk of memory. Also, the name `lpPweParam' suggests that it's a pointer. With pointer you need to use operator `->':
PWEPARAM pweParam = { ... };
pweParam.lptstrFolder = new WCHAR[someNumber];
....
wcscpy(pweParam.lptstrFolder, L"Hello World");
....
LPPWEPARAM lpPweParam = &pweParam;
size_t nLen = wcslen(lpPweParam->lptstrFolder); // OK
Alex
.
- References:
- Re: setting an instance of an object
- From: SvenC
- Re: setting an instance of an object
- From: Stephanie Doherty
- Re: setting an instance of an object
- From: SvenC
- Re: setting an instance of an object
- From: Stephanie Doherty
- Re: setting an instance of an object
- Prev by Date: Re: dx includes standard?
- Next by Date: Re: CreateProcess and DETACHED_PROCESS flag
- Previous by thread: Re: setting an instance of an object
- Next by thread: Re: setting an instance of an object
- Index(es):
Relevant Pages
|