Click here to Skip to main content
15,899,124 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Auto Load Exployer with auto-loading of a specified file Pin
Larry Mills Sr17-Dec-06 13:27
Larry Mills Sr17-Dec-06 13:27 
GeneralRe: Auto Load Exployer with auto-loading of a specified file Pin
Mark Salsbery17-Dec-06 14:16
Mark Salsbery17-Dec-06 14:16 
GeneralRe: Auto Load Exployer with auto-loading of a specified file Pin
Larry Mills Sr20-Dec-06 14:11
Larry Mills Sr20-Dec-06 14:11 
GeneralRe: Auto Load Exployer with auto-loading of a specified file Pin
Mark Salsbery20-Dec-06 14:20
Mark Salsbery20-Dec-06 14:20 
GeneralRe: Auto Load Exployer with auto-loading of a specified file Pin
Larry Mills Sr21-Dec-06 23:21
Larry Mills Sr21-Dec-06 23:21 
GeneralRe: Auto Load Exployer with auto-loading of a specified file Pin
Mark Salsbery22-Dec-06 4:36
Mark Salsbery22-Dec-06 4:36 
QuestionVC6 is loosing my imports?! Pin
Neounk16-Dec-06 7:56
Neounk16-Dec-06 7:56 
Questionstructure problem (adaptive-sized char type variable in a structure) [modified] Pin
cy163@hotmail.com16-Dec-06 3:02
cy163@hotmail.com16-Dec-06 3:02 
In my program, I need a structure which looks like:
<br />
struct stru_A{<br />
char Name[MAX_LEN];<br />
float score;<br />
}<br />


Moreover, I declare a vector variable of type stru_A to hold Name_Score pairs. My problem arises with the member variable 'Name'.
<br />
vector 'struct stru_A' Name_Score_Collection;<br />
<br />

In the above declaration of stru_A, the size of Name, MAX_LEN, is predefined to be 30(#define MAX_LEN 30, to hold the longest name in my database). However, in the database many peoples' name are much less than 30 letters. Hence, much valuable memory space are wasted. I wonder what's the way to solve this problem.

I have tried with a string variable. It is true it can solve this problem. However, in the later part of my program I need to write each struture in vector Name_Score_Collection into a file on my hard disk. I used CFile::write() to accompolish this. CFile::write() worked fine with 'char Name[MAX_LEN]', but not with 'std::string Name'. I think this is because function write() need to know the exact size for each structure to be write out. The size of a string variable is not fixed.


-- modified at 9:29 Saturday 16th December, 2006
AnswerRe: structure problem (adaptive-sized char type variable in a structure) Pin
Rob Caldecott16-Dec-06 3:15
Rob Caldecott16-Dec-06 3:15 
GeneralRe: structure problem (adaptive-sized char type variable in a structure) Pin
Gary R. Wheeler16-Dec-06 3:22
Gary R. Wheeler16-Dec-06 3:22 
GeneralRe: structure problem (adaptive-sized char type variable in a structure) Pin
cy163@hotmail.com16-Dec-06 3:31
cy163@hotmail.com16-Dec-06 3:31 
GeneralRe: structure problem (adaptive-sized char type variable in a structure) Pin
Rob Caldecott16-Dec-06 3:46
Rob Caldecott16-Dec-06 3:46 
GeneralRe: structure problem (adaptive-sized char type variable in a structure) Pin
Jeffrey Walton17-Dec-06 10:15
Jeffrey Walton17-Dec-06 10:15 
GeneralRe: structure problem (adaptive-sized char type variable in a structure) Pin
Rob Caldecott17-Dec-06 11:01
Rob Caldecott17-Dec-06 11:01 
AnswerRe: structure problem (adaptive-sized char type variable in a structure) Pin
Gary R. Wheeler16-Dec-06 3:22
Gary R. Wheeler16-Dec-06 3:22 
GeneralRe: structure problem (adaptive-sized char type variable in a structure) Pin
cy163@hotmail.com16-Dec-06 3:31
cy163@hotmail.com16-Dec-06 3:31 
GeneralRe: structure problem (adaptive-sized char type variable in a structure) Pin
CPallini16-Dec-06 4:07
mveCPallini16-Dec-06 4:07 
GeneralRe: structure problem (adaptive-sized char type variable in a structure) Pin
Eytukan16-Dec-06 4:10
Eytukan16-Dec-06 4:10 
GeneralRe: structure problem (adaptive-sized char type variable in a structure) Pin
Jeffrey Walton17-Dec-06 10:21
Jeffrey Walton17-Dec-06 10:21 
AnswerRe: structure problem (adaptive-sized char type variable in a structure) Pin
CPallini16-Dec-06 3:42
mveCPallini16-Dec-06 3:42 
GeneralRe: structure problem (adaptive-sized char type variable in a structure) Pin
cy163@hotmail.com19-Dec-06 0:00
cy163@hotmail.com19-Dec-06 0:00 
GeneralRe: structure problem (adaptive-sized char type variable in a structure) Pin
CPallini19-Dec-06 0:11
mveCPallini19-Dec-06 0:11 
AnswerRe: structure problem (adaptive-sized char type variable in a structure) Pin
Michael Dunn16-Dec-06 7:10
sitebuilderMichael Dunn16-Dec-06 7:10 
QuestionGDI+ GetBounds bugs? Pin
moonreflection200016-Dec-06 0:50
moonreflection200016-Dec-06 0:50 
AnswerRe: GDI+ GetBounds bugs? Pin
Mark Salsbery16-Dec-06 9:45
Mark Salsbery16-Dec-06 9:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.