|
did you use the optimizing compiler (with the correct compiler switches set) for the native test?
|
|
|
|
|
How can I make tic-tac-toe game in C++? Plz give me some idea about it.....
|
|
|
|
|
not only cross posting is bad seen, but not following your classes is certainly no the best thing you can do to pass your exams buddy
|
|
|
|
|
How can I make an editor, using C++? I know that I'll have to use graphics also. Bt plzzzzzzzzz guide me how to do this task. I've no idea abt it. Plzzzzz tell....
|
|
|
|
|
i want to learn network programming using C++,someones would tell me how should i start and what websites and books should i enter? thanks
|
|
|
|
|
C++ ? or managed C++ ?
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?
Derek Benner
|
|
|
|
|
Hi All,
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:
extern "C"
int AFX_EXT_CLASS calculate(long lDate)
{
int i = 0L;
//finds diff between current date and lDate
i = FindDateDiff(lCurrentDate, lDate);
if(i < 10)
return 0;
if(i < 20)
return 1;
if(i < 30)
return 2;
if(i < 40)
return 3;
return 4;
}
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.
|
|
|
|
|
ankit_cse wrote: this function sometimes in some environment always returns 4 regardless of the value of i.
No, but there are problems with this code. The "if" statements are not mutually exclusive. They could easily cause logical confusions. You should use "if{}else if{}else{}".
Best,
Jun
|
|
|
|
|
Thanks Jun. Ya I know but this was code existing in my application and the I suppose function sometime incorrectly returns 4.
I hope ur suggestion will solve my problem.
|
|
|
|
|
Hi,
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)?
Thanks for your help
Cheeze
|
|
|
|
|
Actually, P/Invoking unmanaged DLL via DllImport() is dynamic loading. Until the program runs to that point, it won't check if the DLL exists or if the function call has right signature.
Best,
Jun
|
|
|
|
|
cheeze103 wrote: 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.
You can use the exact same code in your managed app too. Just #include the required header files, and link with the required import libs.
|
|
|
|
|
Hi everyone,
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.
thx.
~vikas
|
|
|
|
|
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:
Delegate(this, &function)
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?
|
|
|
|
|
This :-
SendOrPostCallback^ post = gcnew SendOrPostCallback (&Classname::Function)
will instantiate the delegate.
This :-
post(gcnew Object())
will invoke it.
|
|
|
|
|
What's the easiest way to drop a .net control into my native C++ app with minimal impact to the existing app and minimal risk for something breaking?
|
|
|
|
|
Dave Calkins wrote: What's the easiest way to drop a .net control into my native C++ app with minimal impact to the existing app and minimal risk for something breaking?
Is the native app MFC based?
|
|
|
|
|
|
|
thanks I'll take a look at those articles.
|
|
|
|
|
Nishant Sivakumar wrote: Ah, then you can use the WinForms-MFC interop classes.
And thanks to the CP Network errors my reply saying this was not possible and making me look like the idiot I am did not get posted! Yay!
"Alot of the people on this forum are incredibly stupid, thinking that the internet is real" Score: 1.0 in the Soap Box
led mike
|
|
|
|
|
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:
<br />
<br />
<br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include "math.h"<br />
<br />
<br />
int do_crypto(int M, int e, int N);<br />
<br />
int main()<br />
{<br />
<br />
printf("...\n");<br />
<br />
int p = 17;<br />
int q = 11;<br />
int e = 7;<br />
int N = p * q;
<br />
int M = 88;<br />
<br />
int C = do_crypto(M, e, N);
printf("C = %d \n", C);<br />
<br />
<br />
int d = ( ( (p-1) * (q-1) ) / e );<br />
printf("d = %d \n", d);<br />
<br />
<br />
int m = do_crypto(11, 23, 187);
printf("m = %d \n", m);<br />
<br />
<br />
return 0;<br />
}<br />
<br />
int do_crypto(int M, int e, int N)<br />
{<br />
int iret = int ( M * exp(e) ) % N;<br />
<br />
return iret;<br />
}<br />
<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...
|
|
|
|
|
rawstar wrote: *** Please note the 'e' and 'd' are supposed to be superscript, e.g. raised to the power of...
You mean like this?
ENCRYPT: C = Me (Mod N)
DECRYPT: M = Cd (Mod N)
Since this has nothing to do with C++/CLI you might get more eyes on it in the VisualC++ forum.
"Alot of the people on this forum are incredibly stupid, thinking that the internet is real" Score: 1.0 in the Soap Box
led mike
|
|
|
|