Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: apply some fixes #59

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

VoltrexKeyva
Copy link

  • Use the %u format specifier for printing uint32_t.
  • Cast the right-hand side of the condition of the for loop to uint8_t where it was implicitly promoted to int.
  • Use int variable for getchar() since it can return EOF (-1) to indicate an error, char cannot hold negative integers.
  • Use EOF instead of -1 to be idiomatic.

- Use the `%u` format specifier for printing `uint32_t`.
- Cast the right-hand side of the condition of the `for` loop to
`uint8_t` where it was implicitly promoted to `int`.
- Use `int` variable for `getchar()` since it can return `EOF` (`-1`)
to indicate an error, `char` cannot hold negative integers.
- Use `EOF` instead of `-1` to be idiomatic.
@@ -164,7 +164,7 @@ void rotateBoard(uint8_t board[SIZE][SIZE])
uint8_t tmp;
for (i = 0; i < n / 2; i++)
{
for (j = i; j < n - i - 1; j++)
for (j = i; j < (uint8_t)(n - i - 1); j++)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This inline construct may be confusing for beginning programmers.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What alternatives do you suggest? Should I assign the expression to a variable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants