Click here to Skip to main content
15,891,529 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
NewsCode Snippets Manager Pin
marvviki18-Feb-07 2:42
marvviki18-Feb-07 2:42 
Questionmemory mapped I/O and private copies Pin
cruppstahl18-Feb-07 2:28
cruppstahl18-Feb-07 2:28 
AnswerRe: memory mapped I/O and private copies Pin
Waldermort18-Feb-07 3:17
Waldermort18-Feb-07 3:17 
GeneralRe: memory mapped I/O and private copies Pin
cruppstahl18-Feb-07 7:23
cruppstahl18-Feb-07 7:23 
QuestionHow to load text file into an array of structures..? [modified] Pin
Software_Specialist18-Feb-07 2:06
Software_Specialist18-Feb-07 2:06 
AnswerRe: How to load text file into an array of structures..? Pin
Waldermort18-Feb-07 3:11
Waldermort18-Feb-07 3:11 
GeneralRe: How to load text file into an array of structures..? Pin
Software_Specialist18-Feb-07 4:36
Software_Specialist18-Feb-07 4:36 
GeneralRe: How to load text file into an array of structures..? Pin
Waldermort18-Feb-07 5:11
Waldermort18-Feb-07 5:11 
OK, now I see.

For this to work correctly, you must be certain that each customer is layed out the same. IE, if you have yet to create a cost, within the text file you should place 0 and not an empty line.

For the struct, I would do something like
struct CUSTOMER<br />
{<br />
DWORD QuoteNumber;<br />
CHAR  Surname[56];<br />
CHAR  Initials[2];<br />
DWORD CarpetCost; // in Pence/Cents<br />
DWORD DeliveryCost;<br />
SHORT Guarantee; // mind the pun<br />
}


Now since the file is layed out with 5 lines per customer, I would create a function to read a single customer then call this in a loop until there are non remaining.

bool ReadCustomerDetails( FILE* hFile, CUSTOMER* pCustomer )

Open the file with fopen(), read each line with gets() then depending on the which line you read convert it to the datatype in the struct.

Have a go at coding that, need any help just say the word.
GeneralRe: How to load text file into an array of structures..? Pin
David Crow18-Feb-07 16:29
David Crow18-Feb-07 16:29 
GeneralRe: How to load text file into an array of structures..? Pin
Waldermort18-Feb-07 18:24
Waldermort18-Feb-07 18:24 
GeneralRe: How to load text file into an array of structures..? Pin
Software_Specialist19-Feb-07 1:53
Software_Specialist19-Feb-07 1:53 
AnswerRe: How to load text file into an array of structures..? Pin
Bram van Kampen19-Feb-07 13:30
Bram van Kampen19-Feb-07 13:30 
Questiondispaly thambnails of the images on the view Pin
vasu_sri18-Feb-07 0:33
vasu_sri18-Feb-07 0:33 
AnswerRe: dispaly thambnails of the images on the view Pin
Hamid_RT18-Feb-07 4:41
Hamid_RT18-Feb-07 4:41 
QuestionRe: dispaly thambnails of the images on the view Pin
Mark Salsbery18-Feb-07 7:19
Mark Salsbery18-Feb-07 7:19 
QuestionResource Localization (Polish Character) Pin
Anik3318-Feb-07 0:28
Anik3318-Feb-07 0:28 
AnswerRe: Resource Localization (Polish Character) Pin
ovidiucucu18-Feb-07 12:38
ovidiucucu18-Feb-07 12:38 
Questiondisplaying the thumbnail preview of the images on the view Pin
vasu_sri17-Feb-07 22:05
vasu_sri17-Feb-07 22:05 
AnswerRe: displaying the thumbnail preview of the images on the view Pin
Hamid_RT18-Feb-07 4:40
Hamid_RT18-Feb-07 4:40 
GeneralRe: displaying the thumbnail preview of the images on the view Pin
vasu_sri18-Feb-07 19:45
vasu_sri18-Feb-07 19:45 
GeneralRe: displaying the thumbnail preview of the images on the view Pin
Hamid_RT18-Feb-07 20:40
Hamid_RT18-Feb-07 20:40 
GeneralRe: displaying the thumbnail preview of the images on the view Pin
vasu_sri19-Feb-07 22:30
vasu_sri19-Feb-07 22:30 
GeneralRe: displaying the thumbnail preview of the images on the view Pin
Hamid_RT19-Feb-07 23:09
Hamid_RT19-Feb-07 23:09 
QuestionVisual C++ 6 and Windows Vista Pin
D_code_writer17-Feb-07 19:12
D_code_writer17-Feb-07 19:12 
AnswerRe: Visual C++ 6 and Windows Vista Pin
Christian Graus17-Feb-07 19:27
protectorChristian Graus17-Feb-07 19:27 

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.