|
|
Just changed The Visual Studio Build "Character Set" in the
Configuration Properties->General->Project Defaults->character Set to "Not Set" from Unicode
and it worked thankx
|
|
|
|
|
Hi,
How to set null to 2*2 static array in c++ after declaration.
I tried like this
ULONGLONG Array[2][2];
memset(Array,0x0,sizeof(ULONGLONG)*2*2);
What is wrong with this?
|
|
|
|
|
You could initialize it like this -
ULONGLONG Array[2][2] = { {0,0}, {0,0}};
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Or simply:
ULONGLONG Array[2][2] = {0};
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
MPTP wrote: What is wrong with this?
It is not wrong, Anyway Jijo rai's one [^] is much more better.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi All,
I'm a bit perplexed at the behavior of the ShellExecute function. I have two apps. One is called Test.exe, and the other is called suicide.exe. It's pretty obvious what suicide.exe does: it suicides. It deletes itself and Test.exe. When I run suicide.exe manually (dblclicking it), it works fine. Test.exe and Suicide.exe are gone.
Unfortunately, when I try to use a ShellExecute from Test.exe to run Suicide.exe...well, the results are totally disastrous. In the WinMain() function in Suicide.exe, I put a Sleep(2000) followed by DeleteFile("Test.exe"). In Test.exe, after I call ShellExecute(...), I immediately call CDialog::OnClose(). So supposedly, after the ShellExecute function is run, Suicide.exe is supposed to start, and Test.exe is supposed to close itself, then after 2 seconds Suicide.exe kills both files.
That's what should happen theoretically. What is actually happening is that Suicide.exe succeeds in killing itself, but even after the 2 second delay Test.exe is still running. So when it tries to kill Test.exe, it obviously fails. And then, for some unknown reason, Test.exe keeps on starting copies of Suicide.exe forever, until I terminate Test.exe. After I do terminate Test.exe, all the spawned Suicide.exe's are gone, and the two files are also killed.
My two questions: Why does this behavior occur instead of what should occur theoretically? And could anyone help me resolve this?
Thanks in advance.
Btw, it took me quite a lot of thinking to explain this properly. If any part of this is unclear just ask and I'll try my best to explain.
|
|
|
|
|
hmm
You are trying to delete a running exe ? I think the OS may object against that.
Bram van Kampen
|
|
|
|
|
No, I'm not trying to kill a running exe. As I mentioned, Test.exe is supposed to close, and after a 2 second delay Suicide.exe is supposed to delete Test.exe and itself.
My question is why Test.exe doesn't close even when I call TerminateProcess right after I run Suicide.exe
|
|
|
|
|
well, i think you should try to move it into recycler directory.
|
|
|
|
|
Suicide.exe works fine, as I previously mentioned. The problem is getting Test.exe to close BEFORE suicide.exe tries to delete both files.
|
|
|
|
|
hxhl95 wrote: In Test.exe, after I call ShellExecute(...), I immediately call CDialog::OnClose().
I imagine that is NOT closing the dialog or ending the app.
Assuming the dialog is the app's main window:
If the dialog is modal, call EndDialog().
If the dialog is modeless, use DestroyWindow().
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
- whacks myself on the head -
I was nearly going to try exit(0).
Thanks for your help.
modified on Monday, October 13, 2008 1:27 PM
|
|
|
|
|
Hi All,
I'm currently working on my project (which try to perform degree reduction for a Bezier curve).
I've spent a long time trying to find library or useful class to help me perform matrix inversion.
For a degree reduction in Bezier's curve (let's say from degree 3 to degree 2)
B2: bezier curve for degree of 2 (which is unknown in this case)
B3: bezier curve for degree of 3 (which is a given in this case)
M: A matrix involving bezier curves (I already wrote a function to get this matrix)
The fomula to find B2 is as followed:
B2 = inverse(Mtranspose * M) * M * B3
I wrote function to perform matrices multiplication and matrix transpose. I'm having a great deal of difficulty integrating TNT::JAMA_LU and other classes I've found. I just want to do an inverse of a matrix (dimension NxN)
I've spent too much time trying to figure out how to do matrix inversion and that's not even the main point of my project.
Can anyone provide me with good resources? I really appreciate any help in advance.
|
|
|
|
|
You may have a look at Numerical Recipes in C++ [^]. There's also a free online version of the older Numerical Recipes in C book [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Try doing a code search on krugle, koders or google code search. There is some code floating around.
Kevin
|
|
|
|
|
I think I've got an inverse algorithm i can implement in c++...
I got the code in Java...and converted into c++ and into my program.
However.. i ran into some problem..
Please correct me if i'm wrong:
type double in Java is more precise than those in c++. As i'm doing some comparison for example:
if(a>b){
//a might be 0.666666667890 in java
//b might be 0.666666667590 in java
//a might be 0.666666667890 in c++
//b might be 0.666666667590 in c++
and c++ won't detect that a is greater than b
}
what type is more precise than double? perhaps i should try out long double
** edited **
still not doing the job.
any idea?
|
|
|
|
|
xb211 wrote: type double in Java is more precise than those in c++
I strongly doubt about.
For instance Visual Studio 6 compiler uses a 8-bytes double data type , exactly like Java .
xb211 wrote: As i'm doing some comparison for example:
if(a>b){
//a might be 0.666666667890 in java
//b might be 0.666666667590 in java
//a might be 0.666666667890 in c++
//b might be 0.666666667590 in c++
and c++ won't detect that a is greater than b
}
The same (VC6 ) compiler gives the correct result on such a comparison.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: The same (VC6) compiler gives the correct result on such a comparison.
CPallini wrote: xb211 wrote:
As i'm doing some comparison for example:
if(a>b){
//a might be 0.666666667890 in java
//b might be 0.666666667590 in java
//a might be 0.666666667890 in c++
//b might be 0.666666667590 in c++
and c++ won't detect that a is greater than b
}
I meant...
the result I have from c++
a: 0.000000 b: 0.166667
a: 0.166667 b: 0.166667
the result from java
a: 0.0 b: 0.16666641666679166
a: 0.16666658333320838 b: 0.16666641666679166
when comparing a and b...
the 2nd case, c++ will say they are the same whereas in Java, it says they are different.
|
|
|
|
|
I suppose something is lost in traslation.
Check your code.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I just wrote:
double testing = 0.1242923758275093850928390582;
cout << "testing: " << testing << endl;
printf("testing: %f\n",testing);
output:
testing: 0.124292
testing: 0.124292
*** edited ***
I added:
#include <iomanip>
cout << "testing: " << setprecision(20) << testing << endl;
printf("testing: %f\n",testing);
testing: 0.12429237582750939
testing: 0.124292
But.. how do i set the variable itself to have precision of 20 (for example)?
|
|
|
|
|
Interesting.
Try the following with the good old (euphemism) VC6 compiler:
#include "stdafx.h"
#include <iostream.h>
#include <iomanip.h>
void main()
{
double testing = 0.1242923758275093850928390582;
cout << "testing: " << setprecision(23) << testing << endl;
printf("testing: %25.23f\n",testing);
}
</iomanip.h></iostream.h>
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I did:
double testing = 0.1242923758275093850928390582;
double testing1 = 0.1242923758275093850929390582;
or
long double testing = 0.1242923758275093840928390582;
long double testing1 = 0.1242923758275093940929390582;
if(testing1>testing){
cout << "YAY" << endl;
}
it doesn't print out "YAY"
|
|
|
|
|
And what about the Java behaviour with the same inputs?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Ehh.. oops.. i need to re-look at my code!
|
|
|
|