|
Unless there is no need to change the buffer, then the LPCSTR operator is the proper way.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
DavidCrow wrote:
Unless there is no need to change the buffer, then the LPCSTR operator is the proper way.
If there is no need to change the buffer, then it should be explicitly const , in which case you can perform a type-safe cast such as:
CString szString("abcd");<br />
LPCTSTR lpszStr = static_cast<LPCTSTR>(szString);
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
So what is the difference between:
LPCTSTR lpszStr = static_cast<LPCTSTR>(szString); and
LPCTSTR lpszStr = (LPCTSTR) szString;
They both appear to generate the same code. For the purpose of getting read-only access to the internal CString buffer, I'm not seeing a benefit in using static_cast over a traditional cast.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
you mean the advice above ,but i try that method all are dirty shown my UI dialog ,can you speak clearly? thx
|
|
|
|
|
vividtang wrote:
can you speak clearly?
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Let the programmer do the thinking, let the compiler do the work
You can pass a CString object to any function that expects a LPCTSTR, the compiler will extract a pointer to the CString's internal buffer so all you need to do is ...
void foo( LPCTSTR lpszBuffer )<br />
{<br />
}<br />
<br />
<br />
CString strData(_T("12345"));<br />
foo(strData);
The LPCTSTR data type is a pointer to a constant string (ansi or unicode), if you dont have UNICODE defined, LPCTSTR maps to LPCSTR which is defined as "a Pointer to a constant null-terminated string of 8-bit Windows (ANSI) characters" i.e const char *
OR, if all you want to do is to copy the CString buffer to a char[] use strcpy(), strncpy, or _tcscpy(), _tcsncpy() e.g. strcpy(MyBuffer, LPCTSTR(MyCString));
|
|
|
|
|
I have never used them, but how do you arrange for them to be displayed.
My MFC appication has one defined and I have placed some info in it, but then thought how do you display and close it?
|
|
|
|
|
huh ? what Box ? if your MFC app. defined one, maybe you can tell us more about the Box in question ?
oh, it's the "About Box" silly me ...
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
That's the funniest post I've seen in a while!
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Something like this:
CAboutDlg aboutDlg;
aboutDlg.DoModal();
(You may have to include its header)
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
If AppWizard created the application, then the necessary code is in place to display the About box. If it is a dialog-based app, check its system menu. If its an SDI or MDI app, check the toolbar and the Help menu option.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Can anyone help me in building a simple neural network in pure vc++. I'm trying to build a neural network for some image segmentation processes.
|
|
|
|
|
There's a lot of that going around
GOOGLE: VC++ "neural network"
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
yeah i appreciate ur suggestion.... but wht i want is a brief description of how to develop a neural netwrok in VC++, but wht i'm getting a good stuff on neural netwroks from google but not their exact implementation regarding to coding part. Hope u got my point.
|
|
|
|
|
didn't you asked already, 2, 3 times ?
Maybe nobady knows, or don't want to help or cannot divulge "exact" implementation.
Seems to me it's a hard and complex topic, and that helping you directly will mean spending a lot of time teaching you.
another good start(*) : ftp://ftp.sas.com/pub/neural/FAQ.html[^]
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I agree,
While I am no expert on the subject of neural networks I have developing a lossless compression program since May2003. I spend a minimum of 50 hours per week on it and usually closer to 100 hours per week. I have gone as far as to produce a bogus compression program that only has a 1% probability of compression. I leave it complete with source code on disk laying around in my back pack in case someone tries to steal the code while I am not looking. This could waste weeks even months of their time figuring out that it is bogus. Specialty code is prized by many of us.
I do understand that you are only looking for starting point. Your question has sparked an interest for me. I did a search at google.com on neural network and found many great sources...
http://www.cs.stir.ac.uk/~lss/NNIntro/InvSlides.html
http://ieee-nns.org/
http://www-ra.informatik.uni-tuebingen.de/SNNS/
http://www.mathworks.com/products/neuralnet/
http://www.doc.ic.ac.uk/~nd/surprise_96/journal/vol4/cs11/report.html
many many more.
I would also try searching A.I. or artificial intelligence.
Good Luck!
demasoni.com
|
|
|
|
|
pavanbabut wrote:
but not their exact implementation regarding to coding part.
Well this project, found using that same google search, provides full source code download so i don't understand what you are asking for.
http://www.amygdala.org/[^]
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
I have some global variables in my program, but some of them (pointers) suddenly change without me doing it.. How is this possible?
øivind
|
|
|
|
|
By being overwritten, for example. In MSVC++ 6.0, you can set breakpoints on memory changing, this might help you. From the help file:
1. From the Edit menu, click Breakpoints.
2. Click the Data tab of the Breakpoints dialog box.
3. In the Expression text box, type the dereferenced pointer variable name (*p or p->next, for example).
4. Click OK to set the breakpoint.
You might want to consult the help file further (search for Breakpoint AND memory AND change, for example).
|
|
|
|
|
Ok.... dont know if i'm doing things the wrong way, but MSVC.NET gives me the message:
The following breakpoint cannot be set:
When 'g_resManager' changes
Data breakpoints are not supported in the Common Language Runtime.
I also tried to dereference g_resManager (which is a pointer) but that gave the same result..
|
|
|
|
|
Being the happy non-owner of MSVC.NET, I must direct you to the documentation for it. You want to set a breakpoint, and you want to set it when either the variable or the memory address changes. Search, man, search!
|
|
|
|
|
In the debugger, put a conditional breakpoint to see who or what is changing it
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Have you single-stepped through the code to see which statement is writing to the memory address in question? Consider the following:
1) char c1 = 'D';
2) char c2 = 'C';
3) int *i3 = (int *) &c2;
4) *i3 = 1234567; We never directly wrote to c1 or c2 , but c1 got changed indirectly. Setting a breakpoint on the first two statements would not show you anything as the "damage" does not happen until the fourth statement. Make sense?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
makes sense
|
|
|
|
|
Either you are doing it but just don't know your code well enough to to recall where. (This happens more often than you would think), or you are overwriting it thourgh some memory that isn't as big as you think it is. Look for a global array near that point that is one member too small or some such.
You might be able to get a clue by seeing what it was changed to. Pull up your debugger after this happens, and look in memory to see if there is something supicious, not just with the variable overwritten, but also others near that location. If it is a string you have a good clue.
Your confusion on how to find these is one of the lesser reasons to consider global variables evil. (There is sometimes no way to get around them, but the less you have the better, and any you can get rid of is generally good practice)
Good luck.
|
|
|
|