.. (לתיקייה המכילה) | ||
Can we use the "exit" function in this exercise? | |
Yes but it is not recommended. return; from main is much more neat and leads to better and more maintainable code. (why?) |
Can we #include stdlib.h for exit? | |
Yes (how would you use it otherwise?), but its use is strongly discouraged |
Can we use assert.h? | |
Yes, it is recommended (but won't help you in solving). |
What is assert? | |
It is out of scope and not required. Basically, if its argument is false it crashes the program and reports the line and failed condition. As such, it is useful for test-time sanity checks. |
Why does my email not got answered? | |
You're at the right place. See if your issue has already been addressed here. If it was, but answer is unclear - please note that (and what exactly is unclear) in your email. Also please make sure your mail subject is exactly in the format requested in the exercise (which it should anyway be in a polite mail). We get a lot of emails, and the small effort from your side in writing a formatted and informative subject allows us to more efficiently process them and you get faster answers. |
what to do when scanf fails? | |
End the program via return; from main (see the exercise). |
What to do when (scanf succeeds, but) input is wrong? | |
See the exercise and test examples. Generally, request input again until success. |
Do we need to specially handle boards too small to allow victory condition (e.g. 3x3)? | |
No special treatment is needed. just carry on with the game until reached a tie |
My print_board output does not look as in the exercise | |
It's ok, make sure your output matches provided examples |
When I test my solution on the website it outputs weird chars/chinese | |
Check your board initialization (which chars are allowed? - see function documentation. What is the problem if you're initializing board to \0's?). Also, do test your solution on your computer first using i/o redirection. It will be easier to debug. |
Can we assume user inputs only one character when prompted for color? | |
Generally, you cannot assume input to be valid. Specifically - please review the role of the input buffer. Write out which characters the user inputs - no matter which order with respect to printfs (why?), and write out which character(s) each scanf call reads. Can you know which characters belong to color input, and which to the next? (Make sure you understand why you generally don't). |
Can we assume column input is in valid range? How do we treat erroneous input? | |
Generally, you cannot assume input to be valid. See the exercise for instructions and the provided test examples. |
Which material is allowed - up to tutorial 5 or tutorial 7? | |
Up to and including 7 (you may use pointers), although material required is mostly up to 5. In particular, dynamic allocation is not needed in this exercise. |
May we edit the provided code / implement our own versions? | |
Yes, as long as your output matches exercise requirements and expected output, and your code the required conventions and design principles. |
What is the 2nd parameter of print_board? | |
As says the documentation - a 1D array describing board dimensions: number of rows and number of columns (2 elements). |
What is enum? | |
Out of scope. Just an implementation detail of print_board |
Clarification on line counting | |
in C language statements are separated with a semicolon (';') thus each semicolon counts as a line of code (except inside a for command). condition parentheses also count as a line of code. Concatenation of operators and function calls is not an exemption (one line of code per semicolon) |