It's UWAweek 48


This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.
Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.

Displaying selected article
Showing 1 of 919 articles.
Currently 5 other people reading this forum.

 UWA week 36 (2nd semester, mid-semester break) ↓
SVG not supported

Login to reply

7:03am Sat 10th Sep, Christopher M.

> Hi Chris, > I have been able to store details in the files to arrays of struct and I am attempting to loop through each "lines" of the struct to report errors if any are found. I am using the generic for loop syntax (for I=0 I< sizeof struct, I+=) but I found that sizeof doesn't actually report the actual size of the line in the struct itself.
Hi, I'm unsure if it's just your description that is confusing (me), or if it correctly reflects your actual implementation (which, then, is confused). I'll change some of the terminology, as that may help. Firstly, (text) files have 'lines', we read the file line-by-line, storing each line's data into our data-structures - typically arrays (which have 'elements') or structures (which have 'fields/members'). It's usually far better to check the validity of input data as soon as it's read in, not after you've read and stored it all. It may even be the case that invalid data cannot be stored in our data-structures. You've mentioned "arrays of struct" but, hopefully, you meant "an array of structures", where each element of the array is one structure, and the fields of each structure hold the data from each line of the original file. You can iterate over (what was once) each line of the original file, by iterating over each element of the array; so, you'll need to know/save the number of array elements you have. ___ None of the above has even mentioned the size of a structure, and hasn't needed to. Hope this helps,

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  1:17AM Sep 14 2022
Privacy policy