|
Never mind. I just answered my own question. The answer is my application has memory leaks coming out of my ears. I just found an article that explains you need the keyword "virtual" in your destructor declaration. I haven't been doing that. Shame, shame, shame!
In case anyone else finds it useful, here's the link to the article.
|
|
|
|
|
My code was compiled correctly, no errors or bugs. but when I run the program by the time I get to the end I get a fatal exception. Here is my code:
#include "stdafx.h"
#include <iomanip>
#include <iostream>
#include <fstream>
#include <conio.h>
#include <windows.h>
#include <string>
#include <stdio.h>
using namespace std;
struct resident{
char firstName[64];
char lastName[64];
char middleName[64];
unsigned short int ageRes;
string dob;
unsigned long int social;
string eyeColor;
string hairColor;
int height;
char gnd[12];
};
struct family {
string gContact_F;
string gContact_L;
string gContact_f;
string gContact_l;
};
struct term {
char Term[12];
unsigned short int monthTerm;
};
void Resident();
void Stats();
void Term();
void ouFstream();
int _tmain(int argc, _TCHAR* argv[])
{
Resident();
Stats();
Term();
ouFstream();
_getch();
return 0;
}
void Resident(){
resident r;
cout << "\n\tPlease input the residents information below." << endl << endl;
cout << " First Name: "; cin >> r.firstName;
cout << " Middle Name: "; cin >> r.middleName;
cout << " Last Name: "; cin >> r.lastName;
cout << " Age: "; cin >> r.ageRes;
cout << " Date of Birth: "; cin >> r.dob;
cout << " SSN#: "; cin >> r.social;
cout << " Eye Color: "; cin >> r.eyeColor;
cout << " Hair Color: "; cin >> r.hairColor;
cout << " Height: "; cin >> r.height;
cout << " Gender: "; cin >> r.gnd;
cout << endl << endl;
}
void Stats(){
family s;
cout << "Family Contact(1)." << endl << endl;
cout << " First Name: "; cin >> s.gContact_F;
cout << " Last Name: "; cin >> s.gContact_L;
cout << "\t---------" << endl;
cout << "Family Contact(2)." << endl << endl;
cout << " First Name: "; cin >> s.gContact_f;
cout << " Last Name: "; cin >> s.gContact_l;
cout << endl << endl;
}void Term(){
term t;
cout << "Long term/Short (L/S)" << endl << endl;
cout << " Term: "; cin >> t.Term;
cout << " Month(s): "; cin >> t.monthTerm;
cout << endl << endl;
}
void ouFstream(){
char MM[64];
char DD[12];
char YYYY[12];
char mm[64];
resident R;
cout << "Input date of application." << endl << endl;
cout << " Month: "; cin >> MM;
cout << " Day: "; cin >> DD;
cout << " Year: "; cin >> YYYY;
strcat (MM, "_");
strcat (MM, DD);
strcat (MM, "_");
strcat (MM, YYYY);
strcat (MM, "_mem#_");
strcat (MM, R.lastName);
ofstream output;
output.open("Healthcare_Statistics.txt");
if(output.fail()){
cout << "Failed opening file: " << output << "!" << endl;
exit(1);}
}
|
|
|
|
|
Well, your best friend is the debugger (see the call stack window). Anyway using cin & strcat that way can easily make exceptions occur.
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]
|
|
|
|
|
Like CPallini replied, there is probably some buffer overflow that is happening with the cin/strcat combination.
I suggest you initialize all local variables and local structure variables to zero before using them.
Next I suggest you replace cin >> with cin.getline where you can specify a maximum count of characters to read.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
You should be able to eliminate 90% of this code and still be able to reproduce it. Narrow the problem down to just a handful of statements.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hello,
i need help regarding an ActiveX issue.
I have ported a graphical qt4.4 thread/socket application from an exe to a activeX dll.
--> ethernet/socket communication will be done in one sep. thread
The application displays a live image from a cam via ethernet/sockets.
Now i have following issue.
In the normal exe application the image displaying is fast/no interruptions.
If i test the activex dll in a container (same source as exe) the image updateing is not jerk-free!?
What can i do to improve it?
Please help.
I'm thankfully for any ideas, tipss etc...
thank you,
best regards,
|
|
|
|
|
If a file (maybe exe, txt, html, chm etc) is copied, installed or uploaded to everywhere - such as compressed or uncompressed Windows OS, UNIX, Apple etc and in different place (US, AU etc) - and viewed, executed (but not modified or edited):
does Last modified file time related to WIN32_FIND_DATA and function FindFirstFile(...) keep constant and unchanged?
I nned the info for auto-update software.
|
|
|
|
|
I will suggest you use a hash function, for example MD5, for checking if a file has been modified ot not.
-Saurabh
|
|
|
|
|
My static linked MFC exe file is over 7M now, I think it shouldn't be so large.
I have tried two ways to reduce its size:
- Change resource bmp files from 24 bits to 16 bits
What software can do the change?
As I tested, both PaintBrush and PhotoShop (version 6) can not do.
How about CorelDraw? I have CorelDraw but didn't install.
- Exclude some lib files.
I did nothing for this, because I don't know how to detect which lib is unused and how to disable it.
Do you have any idea to reduce exe size with detail hints?
|
|
|
|
|
If you link statically to MFC, you're exe size is going to get bigger.
You should have the option of using the shared version of MFC, if you want to really think about a small exe size.
There are also other techniques of combining sections and using the proper compiler switches.
Here are a few articles on reducing the size of the exe -
http://msdn.microsoft.com/en-us/magazine/cc301696.aspx[^]
http://www.catch22.net/tuts/minexe[^]
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
the mspaint.exe can convert 24bit true color image to 16bit ones.
|
|
|
|
|
Member 4470227 wrote: the mspaint.exe can convert 24bit true color image to 16bit ones.
Paint sucks on decreasing color depth. Irfan View , for instance, is really 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]
|
|
|
|
|
try UPX to pack and compress your executeable files.
|
|
|
|
|
Member 4470227,
I don't know software you mentioned.
Is mspaint.exe PaintBrush or Paint program of Windows default tool?
Or how to get them for free?
|
|
|
|
|
|
The paint program is pbrush.exe, and has been part of the OS install since Windows 3, if not before. It's got better as the years go on though!
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
couldn't you use JPEG instead of BMP images? depending on size and complexity JPEG tends to compress images by a factor of 3 to 10 to 30.
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
With Visual Studio 2005, under Linker Optimization, make sure you are eliminating unreferenced data, enable COMDAT folding and set Optimize for Windows98 to No.
Check if you are overusing templates. They tend to chew up a lot of space. You could also turn off intrinsic functions. Under code generation, turn off "Buffer Security Check" (some will disagree, if you read up on it, you'll find it's nearly useless, but does use space.) Under Language, i always turn of Run-Time Type Info (savings is small, but I never use it so why not?) Reexamine everything you are linking to; sometimes you use a tiny function that pulls in a huge amount of code even though you don't really need it.
If your resource bitmaps are big, consider PNG or JPG.
|
|
|
|
|
includeh10 wrote: Change resource bmp files from 24 bits to 16 bits
What software can do the change?
As I tested, both PaintBrush and PhotoShop (version 6) can not do.
How about CorelDraw? I have CorelDraw but didn't install.
Decreasing the color depth may do the trick, provided you have many big images. Anyway this doesn't affect the executable's size when it is loaded in memory, I guess (unless you dynamically load, and then discard, images).
IrfanView [^] a freeware image viewer, is very good in decreasing image color depth.
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]
|
|
|
|
|
Decreasing the color depth may do the trick, provided you have many big images. Anyway this doesn't affect the executable's size when it is loaded in memory,
//-----------------------------------
It does affect exe size, when I change bmp from 24 bits to 256 color, exe size becomes smaller.
|
|
|
|
|
#include <iostream>
using namespace std;
class CTestA
{
public:
virtual void FuncA()
{}
private:
int m_iValue1;
char m_cValue1;
int m_iValue2;
char m_cValue2;
double m_dValue1;
};
class CTestB : public CTestA
{
public:
virtual void FuncB()
{}
private:
};
void main()
{
cout << sizeof(CTestB) << endl;
system("pause");
}
Why the output is '32', while my expected is '28'.
|
|
|
|
|
carter2000 wrote: Why the output is '32', while my expected is '28'.
How are you calculating 28? By adding size of individual members? If yes, see what MSDN is saying.
When the sizeof operator is applied to a class, struct, or union type, the result is the number of bytes in an object of that type, plus any padding added to align members on word boundaries. The result does not necessarily correspond to the size calculated by adding the storage requirements of the individual members.
|
|
|
|
|
|
Structure sizes don't work that way - there may be (will be in this case) be padding between items of different types in a structure, dependent on the type's default alignment. Have a look at this Wikipedia page[^] that explains the concept.
However, there is a way around the default alignments, using #pragma pack to alter structure packing. So, if you put the following line before your structure definitions, you'll find you get the output you expect:
#pragma pack(1)
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks. I add "#pragma pack(4)", and it works as I wish.
|
|
|
|