|
DavidCrow wrote: PathRemoveFileSpec()
Yup, I was just trying to spot this guy, found and used it here[^].
Btw David, I have a simple question related to above, If you want to clear a char buffer[] (stack allocated) , what's the proper way?
like :
char szTemp[256];
<br />
strcpy(szTemp,"");<br />
*szTemp = 0;<br />
ZeroMemory(..)<br />
Memset(..)<br />
*szTemp = NULL;<br />
|
|
|
|
|
VuNic wrote: If you want to clear a char buffer[] (stack allocated) , what's the proper way?
like :
char szTemp[256];
I would use:
char szTemp[256] = { '\0' }; for initialization, and then memset() later on to clear its contents.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Dear all
after i debugged my system, output showed me below: DlgOpenCylinder.cpp(376) : error C2601: 'OnCypasteImage' : local function definitions are illegal
Error executing cl.exe.
how to resolve this issue?
thanks
Li Zhiyuan
15/092007
|
|
|
|
|
probably missing a closing '}' on a function. Look just above the first error.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
li zhiyuan wrote: how to resolve this issue?
By reading here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I suggest you read the first post in this forum titled "How to get an answer to your question".
|
|
|
|
|
shpid3r wrote: As for now, I have only discovered ExtTextOut(), to which I must provide x,y coordinates for starting to write at, and which doesn`t automatically add a scrollbar when reached the end of the screen.
So, did any of you find or know a better solution to this ?
It sounds like you should use a rich text control. If you are using MFC, you can use CRichEditCtrl.
Nathan
|
|
|
|
|
Hi,
If an application has more than one top level windows,
how can I determine which is the main window.
Thanks!
|
|
|
|
|
What defines the "main window"?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Today a fishing day for you?
|
|
|
|
|
I hear the familiar cry heard on sportfishing boats...
"HOOK UP!!!"
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I receive a 20 word message and two words of this message define a floating value;
unsigned short message [20]; // Message buffer
e.g. message [2] and message[3] define a float with the mantissa in the lower byte of message[3].
Could I get the floating value by doing this:-
buffer[0] = message[2];
buffer[1] = message[3];
union
{
float data;
unsigned short buff[2];
}convert;
float val = convert.data;
Or what is the best way to get this 32 bit embedded floating point value.
Andy.
|
|
|
|
|
Andy202 wrote: Could I get the floating value by doing this:-
Have you tried it to find out?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yes, get funny results
Sorry code error see corrected code below:-
union<br />
{<br />
float data;<br />
unsigned short buff[2];<br />
}convert;<br />
<br />
convert.buff[0] = message[2];<br />
convert.buff[1] = message[3];<br />
<br />
float val = convert.data;
|
|
|
|
|
Will two unsigned short s hold both parts of a float ? Since a float is four bytes, perhaps you should use four unsigned short s.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks David. The code below seems to work OK.
But I am sure they must be a better way to get the result!
unsigned short w1 = 0xc3f5;
unsigned short w2 = 0x4840;<br />
union<br />
{<br />
float data;<br />
unsigned short buff[2];<br />
BYTE floating[4];<br />
}convert;<br />
<br />
convert.floating[0] = (BYTE)(w1/256);
convert.floating[1] = (BYTE)(w1 & 0x00FF);<br />
convert.floating[2] = (BYTE)(w2/256);<br />
convert.floating[3] = (BYTE)(w2 & 0x00FF);<br />
<br />
<br />
float val = convert.data;
|
|
|
|
|
Perhaps, it is possible, that you wrong the order of
convert.buff[0] = message[2];
convert.buff[1] = message[3];
it can be also
convert.buff[<code>1</code>] = message[2];
convert.buff[<code>0</code>] = message[3];
check this looking to the memory-watcher of VS during DEBUG.
(float usually are 4 bytes, unsigned short can be 2 bytes, elseway DavidCrow gave you a good tip)
Russell
|
|
|
|
|
I like it
Russell
|
|
|
|
|
Andy202 wrote: I receive a 20 word message and two words of this message define a floating value;
unsigned short message [20]; // Message buffer
e.g. message [2] and message[3] define a float with the mantissa in the lower byte of message[3].
Could I get the floating value by doing this:-
union
{
float data;
unsigned short buff[2];
}convert;
convert.buff[0] = message[2];
convert.buff[1] = message[3];
float val = convert.data;
Or what is the best way to get this 32 bit embedded floating point value.
Andy
Something like that would work if you used the fixes I made in your quote. However, it would be easier to just use
float result = *(reinterpret_cast<float *>(message + 2);
|
|
|
|
|
Thanks, that work great.
Andy.
|
|
|
|
|
Hey guys,
I'm writing a little class that will read data from a file and store it as a string. This data can be either text or a number.
string strHold = csvTable->getValue(row, column);<br />
<br />
char* chHold;<br />
strHold.copy(chHold, strHold.length());<br />
<br />
return atoi(chHold);
I know that atoi() will return a 0 if the value of chHold = "This is not an int," So my question is : what is a good way to check if the zero is actually the number 0 and not a returned zero as the result of atoi("This is not an int").
[Insert Witty Sig Here]
|
|
|
|
|
chHold == "0" ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
so chHold == "0"
would be differnt than
chHold = 0
where "== "0" test for char and "= 0" tests for int?
im going back to c++ 101, its friday morning and im not thinking at all apparently
[Insert Witty Sig Here]
|
|
|
|
|
VonHagNDaz wrote: so chHold == "0"
would be differnt than
chHold = 0
well since the second is an assignment operation.... yeah that's pretty much different.
|
|
|
|
|
come on mike, ive already had a massive brain fart this morning, i dont need you fanning it back at me, the initial wiff was enough...
[Insert Witty Sig Here]
|
|
|
|