It's UWAweek 48

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 the 6 articles in this topic
Showing 6 of 919 articles.
Currently 1 other person reading this forum.


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

Login to reply

👍?
helpful
1:29pm Tue 6th Sep, ANONYMOUS

This is probably a really simple solution (and silly question) but how do we convert a char symbol to an int? I want to check if the given string is a symbol before returning an int value that's associated with that symbol but when I print the values, they are either wrong and not consistent. This is what I'm currently doing: E.g. if (strcmp(value, '.')) { int val = 1; return val; } Thanks.


SVG not supported

Login to reply

👍?
helpful
2:01pm Tue 6th Sep, ANONYMOUS

For example, I'm printing the minute and hour values but since the first two lines of the crontab files are '*', my functions aren't returning -1. I've made sure to check if the string is an '*' and if so, return an int. I've tried placing the condition check above my loop in these individual functions but then it just returns -1 for every line. Don't know what's going on.



This article has 1 attachment:

 

SVG not supported

Login to reply

👍?
helpful
5:48pm Tue 6th Sep, Matthew C.

I think what you are asking is how to get the ascii value of a symbol character. That would be typecasting: char c; int x; x = (int)(c); I think you are probably trying to check if a crontab "word" is an asterisk. I think there are easier ways than what you are trying to do.


SVG not supported

Login to reply

👍?
helpful
6:12pm Tue 6th Sep, ANONYMOUS

"Matthew Carlsen" <23*8*8*[email protected]*u*e*t*u*a*e*u*a*> wrote:
> I think what you are asking is how to get the ascii value of a symbol character. > That would be typecasting: > > char c; > int x; > > x = (int)(c); > > I think you are probably trying to check if a crontab "word" is an asterisk. > I think there are easier ways than what you are trying to do.
Thanks for the reply. I'm looking to check if the 'word' is an asterisk, and if it is, then 'convert' it to an int such as -1 for future use and storage.


SVG not supported

Login to reply

👍?
helpful
9:18pm Tue 6th Sep, ANONYMOUS

All good, I've managed to get it. I was missing important syntax.


SVG not supported

Login to reply

👍?
helpful
7:23am Wed 7th Sep, Christopher M.

ANONYMOUS wrote:
> E.g. if (strcmp(value, '.')) {
This code is invalid and, if you're compiling your code with correct/strong arguments, the compiler will announce it as an error. You are passing a string (value) as the first parameter to strcmp(), and a single character ('.') as the second, but strcmp() expects two string parameters.

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