|
Use strtok:
LPCTSTR szSentence = _T("This is the stuff.");
LPCTSTR pszWord;
pszWord = _tcstok ( szSentence, _T(" ") );
--Mike--
"Everyone has figured out what 'service pack' really means, so they had to go and change the language. Perhaps this is what Bill was talking about in the 'security is top priority' letter."
-- Daniel Ferguson, 1/31/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
http://www.codeproject.com/string/tokenizer.asp
<br />
CTokenizer tok("This is my Sentence", " ");<br />
CString sen;<br />
<br />
if(toh.Next(sen))<br />
sen.GetLength();<br />
<br />
Think this is right
Josh
|
|
|
|
|
Another method, if you happen to like iostream s:
std::string sentence="One ring to bind them all";
std::string first_word;
std::istringstream(sentence)>>first_word;
std::string::size_type length_first_word=first_word.size();
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hey all.
new/delete in there default implementation use the default heap returned by GetProcessHeap()(????)
If this is correct, does this mean I could manually detect memory leaks by comparing the HeapSize at startup to HeapSize at destruction...?
What about detecting GDI, or Virtual, GLobal, Malloc memory leaks...?
Can I use GlobalMemoryStatus() again to find the difference of memory useage(Would indicate memory leakage???) at startup and destrcution...? This probably wouldn't be that accurate huh...? How do tools like Stress return there values, is this an example of GlobalMemStatus()...?
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
new/delete uses a private heap, so I'm afraid GetProcessHeap won't do. Fortunately, in debug mode you can use <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/_crt__crtmemdifference.asp">_CrtMemDifference</a> and related functions (in <crtdbg.h> ) to check for memory leaks caused by C run-time library allocations (malloc , realloc and new ).
As for other functions that also allocate memory, I don't know (right off the top of my hat) of any easy method to detect leaks.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanx again Joaquín.
This will do for now...
Cheers
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Hello,
I have problems in one of my applications (others are very similar and without this problem).
The problem is:
When I run application I've got ASSERTION FAIL in file DOCSINGL.CPP at line 216
// use generic 'untitled'VERIFY(strDocName.LoadString(AFX_IDS_UNTITLED));
I don't know why it cannot find string with ID AFX_IDS_UNTITLED. If I define it manualy in a string table, I can run just a Debug version. A Release version give me unhandled exception in KERNEL32.dll
I included all standard files(afxres.rc,...).
Can anybody help me please?
Thanks
Peter
|
|
|
|
|
Try with the "Rebuild all" command. Sometimes the dependency engine goes nuts and plays little tricks like that.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
I am trying to copy the contents of the returned value of this function into a variable:
LPWKSTA_INFO_100 pBuf = NULL;
NET_API_STATUS nStatus;
nStatus = NetWkstaGetInfo(NULL, 100, (LPBYTE *) &pBuf);
But I do not want to specify any hardcoded sizes and I do not want to use any CString or strings. what's the best way of doing it? the only thing I have managed to get so far is this:
wsprintf(tcUser, "%200S", pBuf->wki100_computername);
but I am still specifying a size. Any other ways of doing this?
|
|
|
|
|
CString str;
str = _T(pBuf->wki100_computername);
Regards...
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Probably something like this:
TCHAR* name = new TCHAR[lstrlen(pBuf->wki100_computername)];
lstrcpy(name, pBuf->wki100_computername);
Of course, don't forget to delete[] name.
CodeGuy
The WTL newsgroup: over 1100 members! Be a part of it. http://groups.yahoo.com/group/wtl
|
|
|
|
|
how about memcpy?
I was wondering if I use memcpy, how do I get the string length of the second member of the structure which is pBuf->wki100_computername as my attempts in using strlen and its variations haven't been successful?
|
|
|
|
|
There shouldn't be any reason why strlen/lstrlen wouldn't work unless you are having a syntax problem or a more serious coding problem.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
Well, first off you've got a problem in that you're passing the address of a pointer to the API, not the address of a WKSTA_INFO_100 struct. That's gonna corrupt your stack.
Once you fix that, use ATL's W2CT macro to convert from WCHARs to TCHARs, then _tcsdup to make a copy of the string.
USES_CONVERSION;
LPCTSTR pszCompName;
pszCompName = _tcsdup ( W2CT(buf.wki100_computername) );
if ( NULL == pszCompName )
free ( pszCompName );
--Mike--
"Everyone has figured out what 'service pack' really means, so they had to go and change the language. Perhaps this is what Bill was talking about in the 'security is top priority' letter."
-- Daniel Ferguson, 1/31/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
Hi,
I created a MDI app with a CRicheditView.
Works fine but I'd like to modify the Richedit style, i.e. add auto horizontal scroll to avoid line wrapping.
usualy, this is done through create(style, .....).
But I can't find where the richedit is created in the MDI appwizard generated code
help !
|
|
|
|
|
Check this:
CRichEditView::GetRichEditCtrl
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
yeah, knew this one.
the problem il that I see only the SetOptions() method to change style, I tried :
GetRichEditCtrl().SetOptions(ECOOP_SET, ECO_AUTOHSCROLL |<br />
ECO_WANTRETURN | ECO_AUTOVSCROLL);
but seems to change nothing.
|
|
|
|
|
Yes,you are right ,it doesn't work.
There is MFC sample in MSDN,WORDPAD ,maybe it helps you ,I don't
have it to check it,if you find the answer in it please reply me.
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
wordpad sample does it. I just can't figure how...
<psycho scream> AAHAHAHAHAAAHAHAHAHHAHAHAHAHA </psycho scream>
I'll go to sleep, local time is 23:48.
|
|
|
|
|
I work on it a little,we have to change "wrap" property
In the example in "option" dialog box it change radio button
to no wrap but I couldn't found where it take effect,I put new message,maybe
someboddy HELP us
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
I'm looking at "Sams Teach Yourself Visual C++ 6 in 21 Days" and for the code on page 78, I get the following error for line 23's code in the book:
--------------------Configuration: Timers - Win32 Debug--------------------
Compiling...
TimersDlg.cpp
C:\WINDOWS\Desktop\Rajveer\Timers\TimersDlg.cpp(203) : error C2196: case value '1' already used
Error executing cl.exe.
TimersDlg.obj - 1 error(s), 0 warning(s)
I checked all my code for that entire project and I've typed it exactly as the book. So what is wrong?
|
|
|
|
|
Um... hard to say without seeing some code.
/ravi
"There is always one more bug..."
ravib@ravib.com
http://www.ravib.com
|
|
|
|
|
Ravi Bhavnani wrote:
hard to say without seeing some code
The operative word here is "some" I guess. I mean we dont want someone posting an entire project over here huh?
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Not again.
J
|
|
|
|