Search:

Type: Posts; User: laserlight

Page 1 of 20 1 2 3 4

Search: Search took 0.08 seconds; generated 18 minute(s) ago.

  1. Replies
    9
    Views
    131

    They are identical except for spelling.

    They are identical except for spelling.
  2. Replies
    9
    Views
    131

    That's good to hear. For ease of reading,...

    That's good to hear. For ease of reading, *(*(A+i)+j)) should be written as A[i][j]
  3. Replies
    20
    Views
    272

    Yes, that's a bit of an issue: however, if you...

    Yes, that's a bit of an issue: however, if you look at the Wikipedia article you linked to, you can observe that the latest listed system with a known number of bits in a byte less than 8 was from...
  4. Replies
    9
    Views
    131

    Yes, but unless you're dealing with an array of...

    Yes, but unless you're dealing with an array of array of arrays, there's usually no point passing a pointer to an entire array of arrays. Hence, what you want here is a pointer to the first element...
  5. Replies
    20
    Views
    272

    flp1969 is right: the minimum permitted value of...

    flp1969 is right: the minimum permitted value of CHAR_BIT is mandated by the C standard (since the earliest edition, I believe) to be 8, and the minimum number of bits in an int or unsigned int can...
  6. Replies
    20
    Views
    272

    As I pointed out in my previous post, sizeof is a...

    As I pointed out in my previous post, sizeof is a compile-time operator, except when its operand is a variable length array.


    The C standard states that you are wrong. You must be mistaken in...
  7. Replies
    9
    Views
    131

    x would still be a pointer to the first element...

    x would still be a pointer to the first element of the variable length array
  8. Replies
    20
    Views
    272

    No, unless applied to a variable length array,...

    No, unless applied to a variable length array, sizeof is a compile-time operator.


    You did say "all systems" :p
    Plus it is still good to bother since 8 is a magic number whose meaning is...
  9. Replies
    9
    Views
    131

    Try: void display(int row, int col, int...

    Try:

    void display(int row, int col, int x[row][col])
    I rarely use VLAs so I could be mistaken, but I believe you could leave out the row in the brackets as it's the usual array decay to pointer,...
  10. Replies
    20
    Views
    272

    If a standard integer type is supported, then its...

    If a standard integer type is supported, then its limits would be defined in <limits.h>. The width wouldn't be defined there, but that's what sizeof and possibly CHAR_BIT is for.


    By...
  11. Do you understand the algorithm for counting...

    Do you understand the algorithm for counting repeats when the input is sorted (i.e., see posts #14, #17, and #18)?

    The algorithm for non-sorted input is easy: just sort, then apply the algorithm...
  12. Sorry, I don't understand what you're trying to...

    Sorry, I don't understand what you're trying to say.
  13. Replies
    20
    Views
    272

    Is this just an exercise, or are you deliberately...

    Is this just an exercise, or are you deliberately avoiding <limits.h> and <stdint.h>?
  14. What's the purpose of fun_ptr? Anyway, the...

    What's the purpose of fun_ptr?

    Anyway, the warning is legitimate: you're assigning a function pointer of one type to a function pointer of an incompatible type. You can easily fix this by changing...
  15. Okay, try it with sorted input. Does it work?

    Okay, try it with sorted input. Does it work?
  16. That's because you didn't implement the algorithm...

    That's because you didn't implement the algorithm correctly. Look carefully at what should be in which loop.
  17. Instead of guessing, why don't you go through the...

    Instead of guessing, why don't you go through the algorithm with unsorted input and see what you get, and then implement it and try it for an unsorted array to confirm?
  18. There is a small but critical piece missing...

    There is a small but critical piece missing though: after counting with the inner loop, I must be set to J in order to skip those elements that have already been counted.
  19. Suppose you had input like this: 1 1 1 2 2 3 3 4...

    Suppose you had input like this:
    1 1 1 2 2 3 3 4 4 4 5
    Now, if you want to count the input, it's quite easy: you start with the first number, and set count=1. Then you keep looping over the...
  20. With the first approach, start by sorting the...

    With the first approach, start by sorting the array. Don't worry about the counting yet. You can use the qsort function, or implement your own sort.
  21. Replies
    35
    Views
    496

    That usually doesn't make sense: the point of...

    That usually doesn't make sense: the point of using the static keyword is to give the function name internal linkage. If you declare it in a header, then you're saying that in every separate source...
  22. Which approach are you trying to implement? I...

    Which approach are you trying to implement? I outlined two ways:

    1. Sort then make a single pass to count consecutive numbers of the same value.

    2. Use a second array to map the numbers to...
  23. 1. A static local variable has persistent state...

    1. A static local variable has persistent state (due to static storage duration), but local scope. So you avoid name collisions and can manage the state in a more restricted portion of the program...
  24. Refer to my post #4.

    Refer to my post #4.
  25. That's because you start i at 1 instead of 0.

    That's because you start i at 1 instead of 0.
Results 1 to 25 of 499
Page 1 of 20 1 2 3 4