Search:

Type: Posts; User: gaxio

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Replies
    18
    Views
    457

    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...
  2. Replies
    18
    Views
    457

    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...
  3. Replies
    18
    Views
    457

    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...
  4. Replies
    18
    Views
    457

    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;
  5. 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...
  6. 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...
  7. Replies
    3
    Views
    347

    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...
  8. 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.
  9. 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...
  10. 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...
  11. Replies
    4
    Views
    373

    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...
  12. Replies
    4
    Views
    216

    Just remember to index it with...

    Just remember to index it with illegal_squares[y][x], not illegal_square[x][y].
  13. Replies
    20
    Views
    692

    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...
  14. Replies
    11
    Views
    407

    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...
  15. 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...
  16. 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...
  17. Replies
    11
    Views
    407

    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...
  18. Replies
    11
    Views
    407

    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...
  19. Replies
    11
    Views
    407

    I don't understand what you're asking.

    I don't understand what you're asking.
  20. Replies
    4
    Views
    392

    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.
  21. Replies
    8
    Views
    459

    What are your real goals? Anything that's...

    What are your real goals? Anything that's included with the program can be read by anything with that program. You can't encrypt things because the program would necessarily need to include the...
  22. Replies
    5
    Views
    370

    Line 25 is a crash. You declared a char* which,...

    Line 25 is a crash. You declared a char* which, initially, points to an arbitrary memory location. You then pass it to scanf which will write to that location. Your compiler should be warning you...
  23. Thread: malloc function

    by gaxio
    Replies
    7
    Views
    446

    Oh, they knew all about bounds checking. It turns...

    Oh, they knew all about bounds checking. It turns out that this is a moderately easy problem to solve from the perspective of a single programmers, but a relatively difficult probably to solve from a...
  24. Replies
    3
    Views
    337

    This isn't what you were asking about, but there...

    This isn't what you were asking about, but there are a few better ways you could arrange those loop.



    for (;;) {
    for(int loop = 1; loop;) {
    // ...
    if(ok) loop = 0;
    }...
  25. Replies
    4
    Views
    327

    You're getting warnings because they're not the...

    You're getting warnings because they're not the same type, you're passing a char a[][11] and it's expecting a char a[]. See my act_on_contiguous example.

    The first thing to understand here is that...
Results 1 to 25 of 57
Page 1 of 3 1 2 3