|
The DLLs were compiled using VC++ 2003, but apparently that doesn't mean they have to target .NET 1.1.
I wrote a little C program to load the DLL and call the function I want. (It exports all its functionality through C function calls so it can be called from an install program.) I have both .NET 1.1 and .NET 2.0 installed on my system. When I debug the DLL using the C program and VC++ 2003, the .NET 2.0 DLLs are the ones that get loaded, not .NET 1.1. Unfortunately, as soon as the CRT 8.0 DLL is loaded, the IDE crashes.
So far as I can tell, there's nothing that lets the DLL say what the minimum or maximum .NET version supported is....
|
|
|
|
|
I need help writing the code to delete from a binary search tree if any body code offer up some C++ code for this it would be greatly appreciated!
|
|
|
|
|
darylesha wrote: I need help writing the code to delete from a binary search tree if any body code offer up some C++ code for this it would be greatly appreciated!
You should ask this in the VC++ forum :-
VC++ forum[^]
|
|
|
|
|
Could some one please help out with this?
We generate random numbers using the random no generator code given below. We generate these random numbers for several applications (up to 200). This means that every application runs this function with different seeds.
long node :: RandomNo(long m)
{
long double k, temp ;
long z;
k = Congruential.Seed / 53668;
Congruential.Seed = 40014 *(Congruential.Seed - k *53668) - k*12211 ;
if (Congruential.Seed < 0)
Congruential.Seed = Congruential.Seed + 2147483563;
k = Congruential.Seed2 / 52774;
Congruential.Seed2 = 40692 *(Congruential.Seed2 - k *52774) - k*3791 ;
if (Congruential.Seed2 < 0)
Congruential.Seed2 = Congruential.Seed2 + 2147483399;
z = Congruential.Seed - Congruential.Seed2 ;
if(z < 1)
z = (long) (z +2147483562) ;
temp = (z * 4.656613) / (10000000000);
z = (long)(temp * 10000000);
z = long( z % long(m+1));
return (z);
}
The seeds are got as per the application number through the function shown below
void node :: SetLinearCongruential(int nno)
{
unsigned long g_lSeed[2]={12345678,23456789};
Congruential.Seed = (g_lSeed[0])*nno;
Congruential.Seed2 = (g_lSeed[1])*nno;
return;
}
The problem is that the random number stop for certain application after a certain point of time.
Example
Average no of application runs - 300,000
Application no runs
35553
46 57889
57 123435
87 67345
This example shows that applications 31,46,57 & 87 have much lower average applications runs as compared to the rest.
These values how ever change when the seed (g_lSeed[i]) value is changed.
We need to ensure that all applications have the same number of runs.
Can some one pls help out?
Thanks in advance
when goin' gets tough, tough gets goin'
amar
|
|
|
|
|
Hi,
I've a big problem. I should set the values of 6 channels from 5.1 sound card (VIA EPIA MII Mainboard
OnBoard Audio: VIA VT1616 6 channel AC’97 Codec; Treiber: vinyl97 6.14.0001.4120). I guess the best way is to do this by using the winmm.dll, mixer API. I tried i lot, but without success. I can set the volume for the master volume, but not for all 6 channels separately.
The other porblem is to set values for frequencies for a graphic equlizer (graphic equlizer like in WinAmp).
Does anybody has an idea how to solve this problem?
great thanks
werner
|
|
|
|
|
There might be a way through the winmm.dll to se the volume independently per channel but the other thing you're talking about (setting up the equlizer) is an application specific task. You can easily tell by changing the settings of the equlizer in winamp and listening on mediaplayer. You should quickly notice there is no cahnge in MediaPlayer when you change settings in winamp. The point being here that there is no windows platform API for operation on the equlizer. For Winamp there is an SDK that you can download from their website.
|
|
|
|
|
I have been given a Connect 4 game engine and have to come up with a "move" function for my AI that returns a column number. My AI will then be run against an opponent's AI to determine a winner or a tie. Can anyone help me with the C++ code for a decent AI?
|
|
|
|
|
|
I have a class called HotelRoom, and I create hotelRooms by doing this:
extern HotelRoom *hotelRooms[10];
in a header file.
This is my try to save this pointer to a file:
void saveFile()
{
char filename[100] = "HotelRegister.dat";
ofstream f(filename);
for (int i = 0; i < 10; i++)
{
f.write((char*) &hotelRooms[i], sizeof(hotelRooms[i]));
}
f.close();
}
void loadFile()
{
char filename[100] = "HotelRegister.dat";
ifstream f(filename);
for (int i = 0; i < 10; i++)
{
//hotelRooms[i] = new HotelRoom();
f.read((char*) &hotelRooms[i], sizeof(hotelRooms[i]));
}
f.close();
}
These 2 functions are aswell extern decleared in the header file.
I have already tested to take away the [i] and for loops but that gives same result, so my conclusion would be that the program crashes(runtime error) because of a memory problem caused by hotelRooms being a pointer and beacause it somewhy doesn't get initialized right?
//for(i = 0; i < 10; i++)
//hotelRooms[i] = new HotelRoom(ROOM_LUXURYCLASS, true, "Hmm kk");
//hotelRooms[i] = new HotelRoom();
//saveFile();
loadFile();
Some of it is commentated because I have tested and switched between those.
I hope someone know about pointers like this alittle better and can help me with this problem
Thanks in advance!
Best Regards,
Hmmkk
|
|
|
|
|
|
Well, as always its you and thanks for answering.
But... It doesn't really "point out" what I need to change in my code unless the thing you wanted to show is that f.read and f.write can be changed to Inserters instead...
Is it really the saving/loading part that is done wrong? Isn't it possible to do it in a similiar way that I showed?
Best Regards,
Hmmkk
|
|
|
|
|
Did I misread the question ? If you want to stream a custom type, you need to write inserters and extractors. Or at least, that is the correct way to do it. What you did looks like it *should* work, but I wouldn't know, I'd never consider doing it that way when iostreams has a nice way of doing it built in.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
i have two WXP installations in two different partitions: i have the need to edit the registry .dat file in the inactive partition. Manually it could be accomplished by using the "load hive" function.
Is there any class to achieve that, programmatically? It seems that all the existing classes are aimed to editing the currently open registry.
Thanks in advances!
|
|
|
|
|
Hi, all. I need some help with a program. I'm not asking you to do the entire thing for me but I won't complain Here is my assignment:
Write a program that uses a stack to return to the user the OCTAL, HEXADECIMAL and BINARY equivalents of a DECIMAL integer input by the user.
EXAMPLE: User_Value 58 base 10 returns 3A base 16, 72 base 8 and 111010 base 2
You need to hand in an algorithm (PSEUDOCODE only) along with the source code and output.
You need to : initialize the stack
check to see if it is full or empty
destroy the stack
PUSH and POP
Can you get me started? I'm sure it's like real easy, in fact I have a nice c program to do the coversion, but I just can't seem to figure how to implement this using a stack. Please, any help would be great. I didn't find this forum till yesterday and my project is due Thursday. Thank you for anything you can provide.
|
|
|
|
|
This is a pseudo-C example of how one would convert a 10-base number to a different base.
It assumes a String class that provides the = and + operators and a Stack class that implements
the push and pop functions.
String BaseConversion(int Number, int Base)
{
int digit;
Stack stack = new Stack();
while (Number >= Base)
{
stack.push(Number % base);
Number = Number/Base;
}
digit = Number
String str = new String("" + digit)
while (stack.NotEmpty())
str = str+stack.pop()
return str;
}
|
|
|
|
|
Thank you so much for your reply! However, I do need just a little more explanation. I know how to create a stack class, but I don't recall string classes; i'm going to go through my texts or search the net for clarification. I do appreciate you including your remarks, and I have some questions. Would I form two versions of this function, one for binary and one for hex, and they would both be seperate calls? Also, my book example showed something like this: If you add 6+3, you push on 6, then 3, and then you pop them off and store them in variables, such as op1 and op2, then perform the addition. I believe the instructor is utilizing a stack for the purpose of something long such as 6+(4*3)/2, should the case ever be necessary. I have not created a stack class before, but one example I was shown uses a case situation, like should you press "+" then it would perform addition, and so on. Thanks again for your time, and look forward to your comments.
|
|
|
|
|
Well, when I first read your post my understanding was that you needed a pseudo-code version of the program. Hence my post...
So, issue number 1: the String class; Now, I'm not sure what language you're planning to use to implement this program so that makes your question a bit hard to answer without further clarification. In classical C++, if I recall correctly, there is the std namespace that I provides a string class (std::string) which should meet the requirement of the code snippet that I have shown above. If you are using a different version of C++ such as the Managed Extentions for C++ (which is really what I think this group should be about, given the "CLI" suffix) there is also a managed String class which is available in the System namespace.
Issue number 2: How to use the function. Basically all you would have to do in your program is call the Convert function as such (example in classical ANSI C++)
<code>
std::string strBase2;
std::string strBase8;
std::string strBase16;
strBase2 = BaseConversion(no, 2);
printf("%d [Base 10] = %s [base 2]", no, strBase2);
strBase8 = BaseConversion(no, 8);
printf("%d [Base 10] = %s [base 8]", no, strBase2);
strBase16 = BaseConversion(no, 16);
printf("%d [Base 10] = %s [base 16]", no, strBase2);
</code>
but I really think that you need to first try to understand more basic concepts in order to be able to take advantage of these posts. Try googling for some tutorials on C++ first (look for basic stuff such as functions etc.), then look for some tutorials on data structures (you need to understand the stack and queue concepts at least).
P.S. the std namespace in C++ should also provide a stack class
-- modified at 22:40 Thursday 10th November, 2005
|
|
|
|
|
how can I replace the array's and do something equivalent. I can't figure out how do change it...... i hav a mental block....
<code></code>
#define MAXVAL 10000000
char primes[MAXVAL];
int main ()
{
// initiallize the primes array
for (/*long*/ int i=0; i<MAXVAL; i++)
{
primes[i] = 0;
}
// Set primes[i] equal to 1 for all not prime numbers
for (/*long*/ int i=2; i</*sqrt((float)*/MAXVAL/*)*/; i++)
{
if (primes[i] == 0)
{
for (/*long*/ int notprime = 2*i; notprime < MAXVAL; notprime+=i)
{
primes[notprime] = 1;
}
}
}
long int test = 0;
// read input one at a time
//while(test>=4)
//{
cout<<"Please input a even integer greater than or equal to 4 : ";
while (cin >> test /*&& test >=4*/)
{
//if(test>=4)
//{
// loop through every possible odd sum
for(long int i=2; i<test/1; i+=1)
{
// if this is a valid prime sum, pring it and break to get the new input
if (primes[i] == 0 && primes[test-i] == 0)
{
int n = test;
int p = i;
int q = test - i;
cout << n << " = " << p << " + " << q << endl;
cout <<"The value of p is "<<p<<endl;
cout <<"The value of q is "<<q<<endl;
break;
}
//else
//cout<<"Invalid input..."<<endl;
//break;
}
//}
}
//}
pause();
return EXIT_SUCCESS;
}
<pre></pre>
|
|
|
|
|
Are you allowed to use the STL ? I'd do this by building a set of prime numbers and checking to see if the number I was given was in it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
my first issue is that i have no idea what is actually happining to cause the leak. To try and find the leak i have commented out most of the code leaving just the basics. First, i create a linked list, then i delete it. thats all thats left of the code. all of the objects of the linked list are deleted and all the nodes are deleted. but something else remains. when i run it, there is a 44 byte memory space still open. my objects are 33 byte (i think). i tried to follow the code as it called new, but was unable to determine who might be calling new and not freeing up.
there are other leaks in the program as well, but i feel that they all resemble this one.
any help or explaination would be greatly appreciated.
int main()<br />
{<br />
_CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF|_CRTDBG_ALLOC_MEM_DF);<br />
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);<br />
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT);<br />
<br />
CatagoryPricingLinkedList* cll = new CatagoryPricingLinkedList;<br />
CatagoryPricing aCat;<br />
aCat.LoadCat(cll);<br />
<br />
delete cll;<br />
return 0;<br />
}<br />
<br />
<br />
<br />
class CatagoryPricingNode<br />
{<br />
public:<br />
CatagoryPricingNode(){}<br />
virtual ~CatagoryPricingNode(){}<br />
<br />
virtual CatagoryPricingNode* InsertCatagoryPricing(CatagoryPricing* aCatagoryPricing)= 0;<br />
virtual void ShowMe()=0;<br />
virtual void Show()=0;<br />
virtual CatagoryPricing* GetCatagoryPricing()=0;<br />
virtual CatagoryPricingNode* GetThisNext()=0;<br />
<br />
<br />
private:<br />
<br />
};<br />
<br />
class InternalCatagoryPricingNode : public CatagoryPricingNode<br />
{<br />
public:<br />
InternalCatagoryPricingNode(CatagoryPricingNode* next, CatagoryPricing* aCatagoryPricing)<br />
{ <br />
m_next = next;<br />
m_CatagoryPricing = aCatagoryPricing;<br />
}<br />
~InternalCatagoryPricingNode(){delete m_CatagoryPricing;<br />
delete m_next;}<br />
<br />
CatagoryPricingNode* InsertCatagoryPricing(CatagoryPricing* aCatagoryPricing)<br />
{<br />
CatagoryPricingNode* aNode = new InternalCatagoryPricingNode(this, aCatagoryPricing);<br />
return aNode;<br />
}<br />
<br />
private:<br />
CatagoryPricingNode* m_next;<br />
CatagoryPricing* m_CatagoryPricing;<br />
};<br />
<br />
class TailCatagoryPricingNode : public CatagoryPricingNode<br />
{<br />
public:<br />
TailCatagoryPricingNode(){}<br />
~TailCatagoryPricingNode(){}<br />
CatagoryPricingNode* InsertCatagoryPricing(CatagoryPricing* aCatagoryPricing)<br />
{<br />
CatagoryPricingNode* newnode = new InternalCatagoryPricingNode(this, aCatagoryPricing);<br />
return newnode;<br />
}<br />
<br />
private:<br />
};<br />
<br />
<br />
class HeadCatagoryPricingNode : public CatagoryPricingNode<br />
{<br />
public:<br />
HeadCatagoryPricingNode(){m_next = new TailCatagoryPricingNode();}<br />
~HeadCatagoryPricingNode(){delete m_next;}<br />
<br />
CatagoryPricingNode* InsertCatagoryPricing(CatagoryPricing* aCatagoryPricing)<br />
{<br />
m_next = m_next->InsertCatagoryPricing(aCatagoryPricing);<br />
return this;<br />
}<br />
<br />
private:<br />
CatagoryPricingNode* m_next;<br />
<br />
};<br />
<br />
class CatagoryPricingLinkedList <br />
{<br />
public:<br />
CatagoryPricingLinkedList()<br />
{<br />
m_head = new HeadCatagoryPricingNode;<br />
pCurrentPtr = m_head;<br />
m_tail = m_head->GetThisNext();<br />
<br />
}<br />
<br />
~CatagoryPricingLinkedList()<br />
{<br />
delete m_head;<br />
};<br />
<br />
void Insert(CatagoryPricing* aCatagoryPricing)<br />
{<br />
m_head->InsertCatagoryPricing(aCatagoryPricing);<br />
}<br />
<br />
private:<br />
CatagoryPricingNode * m_head;<br />
CatagoryPricingNode * m_tail;<br />
CatagoryPricingNode * pCurrentPtr;<br />
CatagoryPricingNode * temp;<br />
};<br />
<br />
class CatagoryPricing<br />
{<br />
public:<br />
<br />
CatagoryPricing(){ <br />
pricelvl1=0;<br />
pricelvl2=0;<br />
pricelvl3=0;<br />
pricelvl4=0;<br />
pricelvl5=0;<br />
costlvl1=0;<br />
costlvl2=0;<br />
costlvl3=0;<br />
costlvl4=0;<br />
costlvl5=0;<br />
totalnumbertoorder=0;<br />
totalinstock = 0;<br />
<br />
};<br />
~CatagoryPricing(){};<br />
<br />
CatagoryPricingLinkedList* LoadCat(CatagoryPricingLinkedList* cll);<br />
private:<br />
<br />
};<br />
<br />
CatagoryPricingLinkedList* CatagoryPricing::LoadCat(CatagoryPricingLinkedList* cll)<br />
{<br />
<br />
CatagoryPricing* aCatagory; <br />
<br />
do <br />
{<br />
aCatagory = new CatagoryPricing;<br />
<br />
<br />
cll->Insert(aCatagory);<br />
<br />
inf.peek();<br />
}while(inf.good());
<br />
inf.close();<br />
return cll;<br />
}<br />
|
|
|
|
|
I guess the first question is, why are you writing a linked list class ? If it's for homework, fair enough. Otherwise, you should use the one that C++ provides.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
to be honest i hate the one C++ provides. i don't like its functionality. but, since all the objects are deleted this still doesn't point to why there is a leak.
|
|
|
|
|
nineofhearts wrote: to be honest i hate the one C++ provides. i don't like its functionality.
Really ? Why ? Surely your linked list does not provide iterators to allow for use with other containers and the algorithm library that comes with c++ ?
I'm looking at your problem
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Sorry, I can't run this code as it stands, because the order of classes is wrong for it to compile.
However, I notice when you call new, you don't put the (). I'm not sure if this makes a difference ? Also, you seem to have a few member variable pointers that don't get initialised to NULL in a constructor, could this be a problem ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
sorry about the code being in the wrong order. didn't consider that when i was cutting and pasting. I tried adding the new() but that didn't help ( and i have never seen it that way in my text) also, initilized the remaining variables with NULL and no change.
as for why i like using my linked list (or more specifically don't like the one C++ provides) ease. mine is simpler for me to use for the little jobs its required to do.
|
|
|
|