PLEASE NOTE: the upgrades to this server,, have not yet been completed.
Hopefully the changes will be completed on THURSDAY 8th December.
Web-based programs, such as csmarks, cssubmit, and the help fora, will be unavailable at some time on Thursday 8th.
  It's UWAweek 49


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 4 other people reading this forum.

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

Login to reply

6:36am Fri 9th Sep, Christopher M.

> Having an issue getting over the segmentation fault hurdle, I have spent days trying different approaches and still cannot figure out where its coming from. To quote Chris' response to another post they "nearly always occur when accessing memory that your process doesn't own, typically by accessing an array outside of its declared dimensions". The problem is my approach to breaking a string into words seems to work for the 1st line of the 1st file read before the fault occurs. I'm using code containing fgets() from the lectures, does that mean the issue is in fgets()? Idk where to even begin if it is...
>From your own example output, it should be clear that fgets() is not the problem - it's your code to break the line (now in a character array) into words, or that you are not converting/storing the words correctly (unsure if you're that far, yet).
Break the problem down into steps of increasing complexity: - can you correctly read/print an empty file? - is that first experiment broken by the addition of comment line(s)? - can you correctly identify lines that are neither comments or commands? - can you correctly read/print a file of just one command line? - does it matter if the date/time fields are always integers, or does adding 1, 2, ... asterisks break things? - does it matter if comment-lines appear before, or after, that single command line? - can you correctly read/print a file of the same command line, repeated 2, 3, .... times? - can you correctly read/print a file of two command lines that differ only in their command-name (6th word)? Have your code call exit() as soon as you reach the end of the file, so that you know the problem is isolated to reading/storing the data. 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