Click here to Skip to main content
15,898,374 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionProblem reading from text file Pin
Ibrahim Bello4-Nov-09 3:22
Ibrahim Bello4-Nov-09 3:22 
AnswerRe: Problem reading from text file Pin
David Crow4-Nov-09 3:51
David Crow4-Nov-09 3:51 
AnswerRe: Problem reading from text file Pin
«_Superman_»4-Nov-09 3:56
professional«_Superman_»4-Nov-09 3:56 
GeneralRe: Problem reading from text file Pin
Ibrahim Bello4-Nov-09 4:22
Ibrahim Bello4-Nov-09 4:22 
AnswerRe: Problem reading from text file Pin
krmed4-Nov-09 7:09
krmed4-Nov-09 7:09 
GeneralRe: Problem reading from text file Pin
Ibrahim Bello4-Nov-09 9:31
Ibrahim Bello4-Nov-09 9:31 
GeneralRe: Problem reading from text file Pin
David Crow4-Nov-09 9:44
David Crow4-Nov-09 9:44 
GeneralRe: Problem reading from text file Pin
Ibrahim Bello9-Nov-09 2:02
Ibrahim Bello9-Nov-09 2:02 
Problem solved and in 3 ways!

1. The "Keep it Simple Stupid" Advice works! Instead of creating an array of MATERIAL i.e Material*, I simply created an array of Material, and accessed each Material by the . notation rather than the ->.

i.e.
g_ptrMaterials = new Material [g_numberOfRows];
Material mat;
mat.temperature = 200.00; // for example


2. One can stuff the structures into a vector:

vector<Material> vctr;
Material mat;
mat.temperature = 200.00; // for example
mat.density = bla bla; 

vctr.push_back(mat);


3. Lastly I modified the initial code. I don't know why it works ...

MATERIAL* arrMaterial = new MATERIAL[g_numberOfRows];
g_ptrMaterial = &arrMaterial[0];

arrMaterial[i] = new Material; //everything works fine now


Perhaps the problem was mixing the malloc and new allocators? I suspected the problem was with the memory allocation, when the compiler continuously indicated errors in xmemory, dbgheap, and what not. It wasn't a v e r y pleasant experience. Anyway, I went for the first option, but one can go for any of the 3 options I suppose, without any harm.

Thanks guys Smile | :)
Questionload image Pin
Arefeh Haghpnah4-Nov-09 3:22
Arefeh Haghpnah4-Nov-09 3:22 
AnswerRe: load image Pin
David Crow4-Nov-09 3:33
David Crow4-Nov-09 3:33 
QuestionCan't create new project in VS 6.0 Pin
ephe4-Nov-09 3:09
ephe4-Nov-09 3:09 
QuestionHow do you profile your C++ code ? Pin
Ahmed Charfeddine4-Nov-09 2:04
Ahmed Charfeddine4-Nov-09 2:04 
Questionis it possible to genarate barcode application using vc++6.0 Pin
eswar pothula4-Nov-09 0:42
eswar pothula4-Nov-09 0:42 
AnswerRe: is it possible to genarate barcode application using vc++6.0 Pin
Jan Sommer4-Nov-09 1:46
Jan Sommer4-Nov-09 1:46 
AnswerRe: is it possible to genarate barcode application using vc++6.0 [modified] Pin
Code-o-mat4-Nov-09 2:22
Code-o-mat4-Nov-09 2:22 
QuestionApplication that communicates with a database - how? Pin
Jan Sommer4-Nov-09 0:32
Jan Sommer4-Nov-09 0:32 
AnswerRe: Application that communicates with a database - how? Pin
David Crow4-Nov-09 2:51
David Crow4-Nov-09 2:51 
GeneralRe: Application that communicates with a database - how? Pin
Jan Sommer4-Nov-09 3:09
Jan Sommer4-Nov-09 3:09 
QuestionHelp in C++ needed Pin
d.project4-Nov-09 0:06
d.project4-Nov-09 0:06 
AnswerRe: Help in C++ needed Pin
Jan Sommer4-Nov-09 0:44
Jan Sommer4-Nov-09 0:44 
GeneralRe: Help in C++ needed Pin
Jan Sommer4-Nov-09 1:03
Jan Sommer4-Nov-09 1:03 
AnswerRe: Help in C++ needed Pin
David Crow4-Nov-09 2:59
David Crow4-Nov-09 2:59 
QuestionGet Installation path Pin
Davitor3-Nov-09 22:46
Davitor3-Nov-09 22:46 
AnswerRe: Get Installation path Pin
Richard MacCutchan3-Nov-09 22:55
mveRichard MacCutchan3-Nov-09 22:55 
GeneralRe: Get Installation path Pin
Saurabh.Garg4-Nov-09 1:11
Saurabh.Garg4-Nov-09 1:11 

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.