Search:

Type: Posts; User: laserlight

Page 1 of 20 1 2 3 4

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

  1. Okay, try it with sorted input. Does it work?

    Okay, try it with sorted input. Does it work?
  2. 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.
  3. 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?
  4. 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.
  5. 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...
  6. 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.
  7. Replies
    35
    Views
    480

    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...
  8. 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...
  9. 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...
  10. Refer to my post #4.

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

    That's because you start i at 1 instead of 0.
  12. It looks like you're practically there. Just...

    It looks like you're practically there. Just print something indicating that the numbers are repeated.

    If you mean repeated more than once in that the numbers have to appear three or more times,...
  13. Use nested for loops. That's where your j...

    Use nested for loops. That's where your j variable can come into play.
  14. Replies
    35
    Views
    480

    This is a very good opportunity to start though:...

    This is a very good opportunity to start though: you're writing a self-contained library such that you don't have to worry about things like mocking a database or a server. Plus it'll look good on...
  15. Replies
    3
    Views
    169

    You're welcome. Declaring a function static...

    You're welcome.


    Declaring a function static affects the linkage of its name. That is, instead of the name referring to that function in all translation units (external linkage, which is the...
  16. Replies
    3
    Views
    129

    Suntani: you posted this twice, and it looks like...

    Suntani: you posted this twice, and it looks like you copied and pasted this from somewhere such that you both asked a question and then appear to address the question. Presently, you're giving me...
  17. Replies
    35
    Views
    480

    Glad to hear that you found and fixed that. ...

    Glad to hear that you found and fixed that.

    Going back to something I think I've mentioned to you before: have you considered automated unit testing? Right now you have what might be called an...
  18. Replies
    35
    Views
    480

    Well, I'm clearly not the only one who disagrees...

    Well, I'm clearly not the only one who disagrees with you: the experts on the C and C++ standards committees disagree with you that this constitutes a significant attack vector. If not, it would be a...
  19. Replies
    12
    Views
    317

    What is your current code?

    What is your current code?
  20. Replies
    35
    Views
    480

    It's not clear to me how that attack would work...

    It's not clear to me how that attack would work in practice without leveraging on another vulnerability, e.g., a typical buffer overflow vulnerability.

    So no, I don't think this warrants...
  21. Replies
    35
    Views
    480

    Such helper functions make your code more...

    Such helper functions make your code more readable. It's true that there might be function call overhead, but on the other hand for functions that aren't good candidates for inlining such overhead is...
  22. Replies
    3
    Views
    169

    This is wrong: static char t[sizeof(*word)] =...

    This is wrong:

    static char t[sizeof(*word)] = "";
    word is a pointer to char, so sizeof(*word) is equal to 1. Hence, t is an array of char that is only large enough to store an empty string.

    If...
  23. I'd suggest reading in a single pass instead. Do...

    I'd suggest reading in a single pass instead. Do this by reading line by line into a sufficiently long string. Check if the line begins with a '#', and if so, you can skip it. Otherwise, parse it for...
  24. davic01: is this supposed to be a C program or a...

    davic01: is this supposed to be a C program or a C++ program?
  25. Replies
    35
    Views
    480

    For alu_vec, have you considered moving expand...

    For alu_vec, have you considered moving expand and shrink into their own functions? For example:

    static int _alu_vec_expand( alu_vec_t *vec, int want, size_t perN, int dir, int used )
    {
    int...
Results 1 to 25 of 497
Page 1 of 20 1 2 3 4