PLEASE NOTE: the upgrades to this server, secure.csse.uwa.edu.au, 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

help2002

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


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

Login to reply

👍?
helpful
11:15pm Tue 6th Sep, ANONYMOUS

> > This is something I think we have to figure out and code-for ourselves. > > > > I am not familiar with the usage of sscanf(), so I can't help with any formatting problems, and in fact I might be entirely misreading your problem here, however it seems to me that a big problem with this code is that not all of the file's values will be integers. Some will, but others will be strings (eg the abbreviations for the days and months "jan" "feb" etc.) and some could be characters, ie " * ". > > > > I don't know if there is a standard function that could correctly perform ALL of these conversions at once, so you'll need to write code to handle each of these cases for yourself. > > > > I'd suggest writing some functions like "month_convert()" that takes parameters of a string and returns an integer corresponding to the described month or to an invalid value. If sscanf() works how I think it does, you can maybe plug this function into sscanf() instead of atoi(), and maybe loop over the various forms the data could take. > > > > Personally, I wrote a sub-function using strcmp() and a while loop that checks if the supplied string (eg "tue") exists within a list of valid data values ("jan", "feb", "mar", ... ,"dec") and returns the index for the identical string in the list.
Regarding this ^, I have a function that checks if the month crontab value is an actual value, such that given a string, if the characters of this string are digits - convert to an int, but if the characters are letters, then check if the string matches a valid value within a list and return its index; this is all done within one function using two separate for-loops. But when I call them and print these values for debugging, the program doesn't run - it's just blank. This is the way I see it working as we must check if the given string characters are either digits or letters, and convert them to their respective int values.
> > Hopefully this will help. If you don't like these any of these methods, there are probably dozens of other ways to go about doing this, you'll just need to be creative enough to think of them. Take a step back, re-evaluate what you actually need to do, and work through it step-by-step. If you can't get a function to do what you want, write your own function instead!

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