|
It might be a good idea to optimize your design a little bit [nothing to do with your nick of course] to avoid having to open 500 plus files at the same time.
Nish
Nish was here, now Nish has gone;
He left his soul, to turn you on;
Those who knew Nish, knew him well;
Those who didn't, can go to hell.
I like to on the Code Project
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
Hi Nish,
Thanks for answering.
Yes you're right, trying to open so many files is not a good idea.
However, it is not my design.
To tell the full story, I have to find a workaround for some application
which I don't have the source code.
This application is opening files all the day using incoming data from the outside.
The basic idea was to make it runs all the day. Then at "midnight", I stop this application, I do a merge on all files created during the day, and I restart the application.
Unfortunately, the incoming dataflow is so high, that the maximum number of file handle is not enough. Also, there is no way to stop the application at noon for instance because this application must run during all business day.
Now, if I can find a way to "patch" msvcrt to open at least 1200 files, then I can use this custom MSVCRT.DLL and make the application run as planned.
Any better idea is welcome.
Regards.
Hassan
|
|
|
|
|
There are articles on this site that relate to injecting your code in place of other code. You could use dumpbin and figure out exactly what imports your "other" app is using and make replacements for those functions with your modified CRT library.
Good Luck.
|
|
|
|
|
I am new to the curious world of MFC. I used the appwizard that created a resource.h file having the following content. Could someone please tell me what is IDM_ABOUTBOX and IDS_ABOUTBOX here. IDD_ABOUTBOX is the default About Boxs' ID in resource Editor. I am confused about the latter two Constants. Please hold my hand !!!
#define IDR_MAINFRAME 128
#define IDM_ABOUTBOX 0x0010
#define IDD_ABOUTBOX 100
#define IDS_ABOUTBOX 101
#define IDD_DIALOG_DIALOG 102
Dont argue with a fool, audience cannot find the difference.
|
|
|
|
|
Those constants are resource identifiers.
Nish
Nish was here, now Nish has gone;
He left his soul, to turn you on;
Those who knew Nish, knew him well;
Those who didn't, can go to hell.
I like to on the Code Project
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
IDM prefix I would think would be the resource identifier thats associated with the about menu appended to your dialogs system menu. IDS prefix is for the string table reosurce.
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
void Investors:: addInvestor(Investor& in)
{
Investor* temp = new Investor[numOfInvestors+1]; //create a new investor array of size of prevArray+1
if (investorsList == NULL) //check if there is something in the array
{
investorsList = temp; //save temp in investorsList
investorsList[0] = in; //fill the first element with the investor that you want to add
} //to your list
else //else if the investorsList is not NULL
{
for (int i = 0; i< numOfInvestors; i++) //in this loop you start copying the elements of the prevlist in
{ //the new temp list
temp[i] = investorsList[i];
cout <
|
|
|
|
|
It doesn't seem to have pasted correctly down the bottom so I'm not sure exactly what's going on, some possibilities:
. you seem to be using investorsList after you've deleted it.
. investorsList=temp; //shouldn't this be done somewhere?
. numOfInvestors++ seems to be done twice
good luck
|
|
|
|
|
It's hard to read code that isn't formatted correctly also, so perhaps use the pre, tag. it preserves your orignal whitespace so tabs actually indent.
if(a==b)
AfxMessageBox("Example of pre tag");
is instead
if(a==b)
AfxMessageBox("Example of pre tag");
Remember to close your tags too!
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
void Investors:: addInvestor(Investor& in)
{
Investor* temp = new Investor[numOfInvestors+1];
if (investorsList == NULL)
{
investorsList = temp;
investorsList[0] = in;
}
else
{
for (int i = 0; i< numOfInvestors; i++)
{
temp[i] = investorsList[i];
cout <<investorslist[i]<<endl;
}
="" temp[numofinvestors]="in;" copy="" the="" new="" element="" in="" last="" position
="" numofinvestors++;="" increment="" numofinvestors
="" delete="" []="" investorslist;="" old="" list
="" for(="" i="0;" i<numofinvestors;="" i++)
="" {
="" investorslist[i]="temp[i];"
="" insertionsort(investorslist,="" numofinvestors);
="" investorslist[numofinvestors];="" numofinvestors++;
}=""
<\pre="">
|
|
|
|
|
Your missing a few brackets and your syntax is a little off.
void Investors::addInvestor(Investor& in)
{
Notice your new is created
Investor* temp = new Investor[numOfInvestors+1];
if (investorsList == NULL)
{
investorsList = temp;
investorsList[0] = in;
}
else
{
for (int i = 0; i< numOfInvestors; i++)
{
temp[i] = investorsList[i];
cout <<investorsList[i]<<endl;
}
temp[numOfInvestors] = in;
numOfInvestors++;
Notice your new is deleted, but what happens if else isn't executed
delete [] investorsList; //delete old list
//This isn't going to make sense to the compiler
for(i = 0; i
{
investorsList[i] = temp[i];
}
insertionSort(investorsList, numOfInvestors);
investorsList[numOfInvestors];
numOfInvestors++;
}
delete should go here unless your if constructs return early
}
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
for(i = 0; i //Your syntax here was off a little { investorsList[i] = temp[i]; }
I could not copy and paste the right code for some reason.
it kept truncating that part of the for statement that you are pointing it to reight above i will try to copy for the last time!
hope it works this time!
void Investors:: addInvestor(Investor& in)
{
Investor* temp = new Investor[numOfInvestors+1];
if (investorsList == NULL)
{
investorsList = temp;
investorsList[0] = in;
}
else
{
for (int i = 0; i< numOfInvestors; i++)
{
temp[i] = investorsList[i];
cout <<investorslist[i]<<endl;
}
="" temp[numofinvestors]="in;" copy="" the="" new="" element="" in="" last="" position
="" numofinvestors++;="" increment="" numofinvestors
="" delete="" []="" investorslist;="" old="" list
="" for(="" i="0;" i<numofinvestors;="" i++)
="" {
="" investorslist[i]="temp[i];"
="" insertionsort(investorslist,="" numofinvestors);
="" investorslist[numofinvestors];="" numofinvestors++;
}="" <\pre="">
|
|
|
|
|
void Investors:: addInvestor(Investor& in)
{
Investor* temp = new Investor[numOfInvestors+1];
if (investorsList == NULL)
{
investorsList = temp;
investorsList[0] = in;
}
else
{
for (int i = 0; i< numOfInvestors; i++)
{
temp[i] = investorsList[i];
cout <<investorslist[i]<<endl;
}
="" temp[numofinvestors]="in;" copy="" the="" new="" element="" in="" last="" position
="" numofinvestors++;="" increment="" numofinvestors
="" delete="" []="" investorslist;="" old="" list
="" for(="" i="0;" i<="" numofinvestors;="" i++)
="" {
="" investorslist[i]="temp[i];"
="" insertionsort(investorslist,="" numofinvestors);
="" investorslist[numofinvestors];="" numofinvestors++;
}="" <\pre="">
|
|
|
|
|
void Investors:: addInvestor(Investor& in)
{
Investor* temp = new Investor[numOfInvestors+1];
if (investorsList == NULL)
{
investorsList = temp;
investorsList[0] = in;
}
else
{
for (int i = 0; i< numOfInvestors; i++)
{
temp[i] = investorsList[i];
cout <<investorslist[i]<<endl;
}
="" temp[numofinvestors]="in;" copy="" the="" new="" element="" in="" last="" position
="" numofinvestors++;="" increment="" numofinvestors
="" delete="" []="" investorslist;="" old="" list
="" for(="" i="0;" i<="" numofinvestors;="" i++)
="" {
="" investorslist[i]="temp[i];"
="" insertionsort(investorslist,="" numofinvestors);
="" investorslist[numofinvestors];="" numofinvestors++;
}="" <\pre="">
|
|
|
|
|
Try this
Investors::Investors(UINT nSize)
{
investorsList = new Investor[nSize*sizeof(Investor)];
}
void Investors::addInvestor(Investor& in)
{
investorsList[numOfInvestors] = in;
insertionSort(investorsList, numOfInvestors);
numOfInvestors++;
}
Investors::~Investors()
{
delete [] investorsList;
}
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
hey HockeyDude;
first of all thank you for your explanations and efforts to solve my dilemma.
but may be i did not mention that I MUST start with an empty array and dynamically cnange its size as i'm adding elements to it!
|
|
|
|
|
Ah...well that adds another layer of difficulty.
Theres no way you can just declare a very large array at construction and fill it in as you go...?
Dynamic resizing isn't easy...I'm working on a class as we speak and i'm not sure i'd be able to fully explain.
First off i don't use new/delete, i use malloc/free.
you have to delete every new at the end of every code block otherwise you get memory leaks.
If you absolutely MUST dynamically resize your array I can only give you pointers...exact code I cannot.
basically use realloc/malloc/free
class CMyClass
{
public:
CMyClass() : m_nCount(0)
{ m_pBuff = malloc(sizeof(Investor)); }
~CMyClass(){ free(m_pBuff); }
void AddInvestor(Investor& newItem)
{
*(m_pBuff+m_nCount) = newItem;
m_nCount++;
m_pBuff = realloc(m_pBuff, sizeof(Investor)*(m_nCount+1)));
}
private:
UINT m_nCount;
Investor* m_pBuff;
};
Note: I don't know for 100% sure the above code is complete, I'm typping from the top of my head. I will however give a starting point.
The code only allocates to a larger size it does NOT shrink itself as required...It assumes there will be NO removal of items once in the array...Also it allocates memory one element at a time...this will fragment your memory. You'd have to allocate large chunks at construction fill them in, then have code in your AddInvestor() reallocate another large chunk and proceed as normal...
All in all this is quite alot of work.
Can I ask what this is for...? Have you considered perhaps using one of MFC's helper classes like CArray...??
It does the Sizing and allocation and stuff for you...
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Man you've been working hard on this stuff man, i don't know how to say thank you.
but the problem is that i must follow the instructor's specification!!!!!
if it depended on me i would have used a linked list but the thing is that i have to use exactly what he said if i don't want to get a zero in my project.
our instructor is so picky!
and as you say "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
i think this is what he wants make us go thru all mistakes??
well anyways here is my latest version of that stupid addInvestor(Investor in) method. see if you trace through it you probably won't find any problems
but the fact is that it adds the first element and crashes same as be4!!!
class Investors
{
// code........
int Investors::numOfInvestors = 0;
Investor* Investors:: investorsList = NULL;
// code........
void Investors:: addInvestor(Investor& in)
{
cout<< in<< endl;
cout<< "numOfInvestors at the beginning: "<< numOfInvestors<< endl;
numOfInvestors++;
Investor* temp = new Investor[numOfInvestors+1];
if (investorsList == NULL)
{
investorsList = temp;
investorsList[0] = in;
}
else
{
for (int i = 0; i < (numOfInvestors - 1); i++)
{
cout << "I am inside the first for loop and i = "<< i<< endl;
temp[i] = investorsList[i];
cout<< temp[i]<< endl;
}
delete [] investorsList;
investorsList = new Investor[numOfInvestors];
temp[numOfInvestors - 1] = in;
for( i = 0; i < numOfInvestors; i++)
{
investorsList[i] = temp[i];
}
insertionSort(investorsList, numOfInvestors);
}
delete [] temp;
cout<<"numOfInvestors at the end: "<< numOfInvestors<< endl;
}
<\pre>
AGAIN THANK YOU:rose: :rose: :rose: :rose: :rose: :rose:
|
|
|
|
|
Send me your cpp/h files unless theres more than one each in email.
It's hard for to lok at this code and guess whats really going on, unless I have the full thing.
Your code is really wide as well, so I keep having to scroll back and forth...It'll be much easier if I can code in my VC workspace.
So you MUST use new/delete for a dynamically growing array...you cannot use malloc and delete...?
That was the reason for the temp array creation...I see...
Yeah like i said..Actually....send me the entire project...that way theres no...missing links...
Cheers
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Zip it too! so I don't get 5-6 files...Just one
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
How can I safely add helpstrings to MFC ActiveX control's ODL file?
I am working on an old activex control and wish to add helpstrings.
After adding the helpstrings, it compiles without any problem and shows in VB class browser.
However, the ClassWizard crashes anytime I try to use it, any tip?
Best regards,
Paul.
Paul Selormey, Bsc (Elect Eng), MSc (Mobile Communication) is currently Windows open source developer in Japan.
|
|
|
|
|
A good whack might do it. (Delete the .clw file)
|
|
|
|
|
Hello -- i have a very wierd problem . i can't create a class starting with a capital C. when i:
Insert-->New Class
Enter the name that starts with a capital C -- the first C doesn't show up in the file name -- but lowercase 'c' works fine. This is as wierd as it gets . . . anybody got a clue on this one
also what is all this crap when i have the wizzards create a class:
#if !defined(AFX_USTOMER_H__E35819DB_8CEA_4883_A2DA_E78053B05B81__INCLUDED_)
#define AFX_USTOMER_H__E35819DB_8CEA_4883_A2DA_E78053B05B81__INCLUDED_
thanks,
tim
---------------------------------------
Tim Booher
|
|
|
|
|
It is not crap . They are called include file guard headers and they are used so that that particular file does not get included twice. The string AFX_USTOMER_H__E35819DB_8CEA_4883_A2DA_E78053B05B81__INCLUDED_ is generated randomly. For eg.
#ifndef _CUSTOMER_H_
#define _CUSTOMER_H_
.
.
.
.
#endif
Atul
Sonork 100.13714 netdiva
|
|
|
|
|
It it Hungarian notation to have all classes begin with a capital 'C'. VC interpret 'Custumer' as 'ustumer'. You could use 'CCustomer' or define your class whitout using the class-wizard.
/moliate
|
|
|
|