Search:

Type: Posts; User: drunken_scot

Search: Search took 0.01 seconds.

  1. Replies
    6
    Views
    2,091

    Your array traversal logic would be correct if M...

    Your array traversal logic would be correct if M were an int **. However, since M is an int *, your row "pointer" must increment by c elements each time, assuming row major ordering.
  2. Thanks for the help. Also thanks for pointing...

    Thanks for the help. Also thanks for pointing out that I need a pointer to a pointer if I allocate the data.
  3. Replies
    30
    Views
    9,180

    Also keep in mind that only one dimension can be...

    Also keep in mind that only one dimension can be unspecified, so foo[ ][ ] is invalid.
  4. This is for the return value. The options I see...

    This is for the return value. The options I see are returning a pointer to the new data or passing a destination pointer to the function and assigning the data there (see original post.)
  5. What if I am using larger structures, say 5 MB...

    What if I am using larger structures, say 5 MB images? I clearly do not want to return that on the stack. Is there a preferred way to return the new data in that case?
  6. Thanks for the help. Part of my question was...

    Thanks for the help. Part of my question was determining a best practice. I was assuming I could not return a structure from a function. As far as asking about structures with pointers in them, I...
  7. I will be modifying the contents of the...

    I will be modifying the contents of the structure. With the first function, I would create the structure and do a shallow copy, which I guess is a rather silly method. I suppose it would get much...
  8. Best Practices for Operations on Structures

    For a program I am working on, I need to perform some operations on vectors, such as vector addition. However, I am unsure of how best to write the functions to perform the operation. My vector is...
  9. I should have clarified rolling a d6 until I...

    I should have clarified rolling a d6 until I don't get a 6. I mean that if I roll a 6 on that die, I keep the 6, roll again and add it to the running total, and if my new roll was a 6, lather,...
  10. My reasoning behind using a linked list was to...

    My reasoning behind using a linked list was to make the Basic_Die able to have multiple internal variables without affecting the outside view of the struct. This way, I could use more or less...
  11. Unfortunately, I am programming in C, but using a...

    Unfortunately, I am programming in C, but using a lookup table is a method I forgot. However, I might be using many different sizes of dice. Further, in Storyteller, usually you score for rolls...
  12. This is proper behavior. I suspect the reason...

    This is proper behavior. I suspect the reason for the difference is that the array size of mins is known at compile time. What happens if you specify



    int sum(int ar[5], int n)


    and take...
  13. Designing Data Structures for Dice Rolling

    For some games I eventually want to program/play in, I want to create a framework that will roll dice in a number of different ways. For my test, I want a polyhedral dice structure, chosen as six...
  14. Replies
    2
    Views
    3,139

    Do you already have the inventory? If not, a...

    Do you already have the inventory? If not, a linked list would be one way to store the data, and it is easy to traverse.
  15. Replies
    16
    Views
    4,867

    line2[j] is not a pointer; the subscript...

    line2[j]


    is not a pointer; the subscript dereferences the pointer. To get a pointer, you can use


    &line2[j]

    or
  16. Replies
    45
    Views
    10,760

    Also keep in mind that you may need to set up...

    Also keep in mind that you may need to set up access to the port, as I/O access is often limited in userspace. If you are operating in kernel space or its equivalent, this shouldn't be a problem.
  17. Replies
    6
    Views
    2,993

    That makes sense. Thanks.

    That makes sense. Thanks.
  18. Replies
    6
    Views
    2,993

    Thanks. I knew Python had something similar for...

    Thanks. I knew Python had something similar for serial ports, but I had forgotten about select's timeout.
  19. Replies
    6
    Views
    2,993

    Thanks. It's nice to know that my...

    Thanks. It's nice to know that my microcontroller work is applicable to a computer system.

    I was looking up sig_atomic_t, and it appears to be typedefed int, with its typedef being performed...
  20. Replies
    6
    Views
    2,993

    Processing both I/O and timed events

    I have some aspirations of one day programming a MUD engine, and I will need to be able to handle both user I/O and timed events. I have written a little program that uses SIGALRM to update the...
Results 1 to 20 of 20