Search:

Type: Posts; User: gaxio

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Replies
    8
    Views
    380

    I realize that, like I said I've seen code like...

    I realize that, like I said I've seen code like this work many times on many platforms and compilers. I'm just asking how to do this without undefined behavior regardless of whether it works with the...
  2. Replies
    8
    Views
    380

    This is surprising, because I've seen code just...

    This is surprising, because I've seen code just like this many times in low level code. For example, you know the address of a group of hardware registers, or memory used by the BIOS, and you address...
  3. Replies
    8
    Views
    380

    Ah, that's where it's from. I wrote it down in my...

    Ah, that's where it's from. I wrote it down in my notebook and couldn't find it again!
  4. Replies
    8
    Views
    380

    Is this undefined behavior in C99?

    I'm reading elsewhere that adding more than one to this pointer is undefined behavior. And I know the code is a bit nonsense, it originates from an exam question and is just meant to demonstrate...
  5. Thread: a 1 bit variable

    by gaxio
    Replies
    5
    Views
    417

    I think you're a bit confused. The smallest...

    I think you're a bit confused. The smallest variable possible is the smallest addressable value by the system. On most systems this is 1 byte, not 1 bit. A char is 1 byte wide and is the smallest...
  6. Replies
    18
    Views
    1,033

    void piece_placement(char board[][ROW_MAX + 1],...

    void piece_placement(char board[][ROW_MAX + 1], char valid_square, char not_valid_square, int column, int row)
    {
    if ((row % 2 == 0) && (column % 2 == 0)) // row and column are even so place a...
  7. Replies
    18
    Views
    1,033

    One thing you'll find yourself doing when writing...

    One thing you'll find yourself doing when writing programs, especially simulations like this, is that they generally follow the same process.


    Data: Select a data structure that represents the...
  8. Replies
    18
    Views
    1,033

    Right, this is the concept of encapsulation....

    Right, this is the concept of encapsulation. However, there are no clear lines between any of files in this program, and this make the entire concept of encapsulation kinda fuzzy here.

    I should...
  9. Replies
    18
    Views
    1,033

    I suppose we can start with a small function. ...

    I suppose we can start with a small function.


    bool toggle_turn(void)
    {
    static bool flag;

    if (flag == true)
    {
    flag = false;
  10. This is actually a different error and not a...

    This is actually a different error and not a segmentation fault, but the principle and causes are the same. A common security vulnerability is overwriting an array on the stack, which will allow you...
  11. Why does C allow you to do this? C has no bounds...

    Why does C allow you to do this? C has no bounds checking. At all. You can read past the end of an array, or before the beginning. C assumes you know what you're doing. Maybe you know there's...
  12. Replies
    3
    Views
    783

    C has no way of automatically freeing things....

    C has no way of automatically freeing things. It's not like in C++ where you have smart pointers that free themselves when they go out of scope or a garbage collected language like C# or Java where...
  13. If your text editor or IDE has a "highlight...

    If your text editor or IDE has a "highlight matching parenthesis" feature, it's a really useful tool for wrangling nested parentheses like this.
  14. I wouldn't stress about displaying anything...

    I wouldn't stress about displaying anything pretty in a text window. Text user interfaces were obsolete 20 years ago and the only thing most people use them for now is running their shell and a text...
  15. You should look into libraries like ncurses. It...

    You should look into libraries like ncurses. It can handle things like clearing the screen, moving the cursor, setting colors, etc in a way that should work on all terminals including Windows...
  16. Replies
    4
    Views
    597

    The easiest way to get started would be Visual...

    The easiest way to get started would be Visual Studio Community. It's a free compiler and IDE from Microsoft and there is no shortage of documentation, tutorials and videos regarding how to install...
  17. Replies
    4
    Views
    313

    Just remember to index it with...

    Just remember to index it with illegal_squares[y][x], not illegal_square[x][y].
  18. Replies
    20
    Views
    2,657

    If you find yourself making a giant switch...

    If you find yourself making a giant switch statement of all possible moves like this, stop and think. In any sort of game or simulation, I don't think I've ever found this to be the best or even an...
  19. Replies
    11
    Views
    992

    Oops, I certainly shouldn't be making mistakes...

    Oops, I certainly shouldn't be making mistakes like that when trying to explain things :p

    This is a very common mistake, though. They've tried to eliminate in more modern languages. In Go, you...
  20. Replies
    3
    Views
    2,589

    No. This is not the same as a 2D array. An int**...

    No. This is not the same as a 2D array. An int** is a pointer to pointers, a 2D array like an int[8][8] is completely different. An int** is what's referred to as a jagged array, it's a number of 1D...
  21. Replies
    3
    Views
    2,589

    First off, let me just give you the answer. From...

    First off, let me just give you the answer. From your other post, the specifics of why this is is probably left to later. Don't worry about not understanding things below this code segment yet. When...
  22. Replies
    11
    Views
    992

    Well... no. *p_x + 1 is an expression that...

    Well... no. *p_x + 1 is an expression that evaluates to the value of x + 1, assuming p_x points to x. *p_x++ increments the value of x, or *p_x += 1.

    Just remember that in declarations *p_x = 0...
  23. Replies
    11
    Views
    992

    I get what you're asking now. The asterisk is...

    I get what you're asking now. The asterisk is thrown around in the syntax for pointers quite liberally and means different things in different places. In the variable declaration as part of the...
  24. Replies
    11
    Views
    992

    I don't understand what you're asking.

    I don't understand what you're asking.
  25. Replies
    4
    Views
    1,112

    Line 84. This is not how you compare strings....

    Line 84. This is not how you compare strings. You're comparing the address of s1 to the address of s2. You'll want to use strcmp, instead.
Results 1 to 25 of 62
Page 1 of 3 1 2 3