i compiled the following code once in c++ and another time in managed c++.
In c++ it takes about 11 seconds to execute and in managed c++ it only takes 5 seconds to execute.
Why do i get twice the speed performance in managed c++ when my code is written completely in native c++ syntax?
double d ;
double e ;
d[i][j] = 0.123456789;
e[i][j] = 0.123456789;
d[i][j] = d[i][j] * e[i][j];
be careful, the 2 are fundamentaly different, even though they are based on the same language basis.
and never forget : google is your friend ! did you only searched the web for what you'd like to learn ? there are tons of examples, tutorials, articles about learning C++, and i don't even talk about the good old paper books...
I've got the source code for an ebook reader that was written for Linux (FBReader) and it uses the GTK+ library and C++. What I'd like to do is re-compile it in VC++ Express. I've got the runtime and developer versions of GTK+ for Windows (courtesy of GIMP) and I'd like to know how to get VC++ to use GTK+ libraries. I'm a Delphi person, with SOME exposure to C++ through the Borland Developer Studio C++ Builder. Does anyone have advice?
This is a very basic question which i need to know. I have a function that has multiple return statements. The code snippet is below:
int AFX_EXT_CLASS calculate(long lDate)
int i = 0L;
//finds diff between current date and lDate
i = FindDateDiff(lCurrentDate, lDate);
I belive this function sometimes in some environment always returns 4 regardless of the value of i. Why?
I have read somewhere that multiple return statements in function is not good programming. Is this true?
Any suggestions appreciated.
I'm trying to dynamically load an unmanaged dll and call a function within it from a managed C++ app. I've managed to do this in an unmanaged C++ app, using calls to LoadLibrary and GetProcAdddress, but don't know what to do in the .NET version. I know there's P/Invoke, but with that the library has to be declared at compile-time, and I won't know the (unmanaged) library until run-time.
So i guess the question is how can I use the LoadLibrary and GetProcAddress functions in managed C++ (again not using P/Invoke, as the library won't be known until run-time)?
I am trying to extract the files/folders information from the Data ISO (Joliet format) images. My motive is to read the information from the PVD (Primary Volume Descriptor), that resides on the begening of the 16th sector of the cd. After reading the information i want to display the files, folders contained in the ISO in terms of sectors.
For example : the data segment of a sector in (ISO)JOLIET format is 2048 bytes. if an ISO image contains following 5 files
A -> 500 byte
B -> 1000 byte
C -> 2000 byte
D -> 100 byte
E -> 400 byte
then in the explorer view the 17th sector(apx.) should display:
File Sector size SpreadFlag
A 17 500
B 17 1000
C 17 548(2000) yes
And sector explorer view for the next sector should display:
File Sector size SpreadFlag
C 18 1452(2000) yes
D 18 100
E 18 400
My query is that: is their any api available which can provide me the details of the ISO image CD in terms of sectors, path table, for the files contained in it or i have to do low level programming to fetch the list of contents available on the ISO image on the CD.
I will greatly appreciate any response provided by you.
I get the most absurd error when I try to instantiate a reference to a SendOrPostCallback, where it refuses to take any System::Object^ for the first parameter for the delegate. Every example I've seen uses C# instead of C++/CLI, and consequently doesn't have this issue. Normally for delegates it's:
Here's my code:
SendOrPostCallback^ post = <br />
gcnew SendOrPostCallback(gcnew Object(), &MessageEvents::MessageEvent::OnMessage);
this, gcnew Object(), and pretty much any other variation I can think of generate the same error,
Error 1 error C3754: delegate constructor: member function 'MessageEvents::MessageEvent::OnMessage' cannot be called on an instance of type 'System::Object ^' c:\Documents and Settings\jmarion\My Documents\Visual Studio 2005\Projects\ManagedServerSocketTest\ManagedServerSocketTest\SocketWrapper.cpp 205<br />
But, no object for the first parameter seems to please the compiler. Thoughts?
Whats the simplest way to pan sound in .NET. I'd rather not use DirectX, and I know the typical way is to pinvoke winmm.dll, but I can't figure out winmm.dll handles balance. I just want to play sound out of specific speakers/channels, for instance moving from right to left.
Hi, probably not the best place for this but maybe someone can help.
For one of my programs i'm trying to impliment my own version of the RSA algorithm, the encryption works fine, however the decrption does not, even though it uses basically the same algorithm. The code is as follows:
// g++ main.c -o main<br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include "math.h"<br />
int do_crypto(int M, int e, int N);<br />
int main()<br />
// TWO PRIMES FOR OUR KEY<br />
int p = 17;<br />
int q = 11;<br />
// THIRD PART OF OUR KEY (PUBLIC)<br />
int e = 7;<br />
// CALCULATE THE OTHER PART OF THE PUBLIC KEY<br />
int N = p * q; // = 187<br />
// THE CHARACTER TO ENCODE AS ASCII<br />
int M = 88;<br />
//int M = "M";<br />
// ENCRYPT A CHARACTER<br />
//int C = int ( M * exp(e) ) % N;<br />
int C = do_crypto(M, e, N); // int M, int e, int N)<br />
printf("C = %d \n", C);<br />
// CALCULATE THE DECRYPT KEY<br />
//int d = ( 1 % ( (p-1) * (q-1) ) ) / e;<br />
int d = ( ( (p-1) * (q-1) ) / e );<br />
printf("d = %d \n", d);<br />
// DECRYPT THE CHARACTER<br />
int m = do_crypto(11, 23, 187); // int C, int d, int N)<br />
printf("m = %d \n", m);<br />
return 0;<br />
int do_crypto(int M, int e, int N)<br />
int iret = int ( M * exp(e) ) % N;<br />
return iret;<br />
When decrypting I have put in actual values for the keys etc, and the result should be 88.
The actual formulas are:
ENCRYPT: C = Me (Mod N)
DECRYPT: M = Cd (Mod N)
*** Please note the 'e' and 'd' are supposed to be superscript, e.g. raised to the power of...
Last Visit: 31-Dec-99 18:00 Last Update: 23-Jun-21 2:50