Search:

Type: Posts; User: christop

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    8
    Views
    195

    This may or may not be related to your problem,...

    This may or may not be related to your problem, but what is the value of "a" at this line: while (a<10){? Hint: you don't know.
  2. One other thing: the "long" type is only...

    One other thing: the "long" type is only guaranteed to support the range -2147483647 to +2147483647. That's not big enough to store a credit card number. (A "long" is 64 bits wide on 64-bit *nix...
  3. Replies
    2
    Views
    132

    The more unixy way would be to take a flag (say,...

    The more unixy way would be to take a flag (say, -v or --verbose) to increase the level or quantity of messages written to stderr. Otherwise a user may be somewhat surprised to find that more is...
  4. Replies
    9
    Views
    307

    BOTH format specifiers must be %lld, as in...

    BOTH format specifiers must be %lld, as in printf("MAIN2: %lld - %lld\n", pair.first, pair.snd);, rather than printf("MAIN2: %ld - %lld\n", pair.first, pair.snd);.
  5. LineStorage is uninitialized the first time fgets...

    LineStorage is uninitialized the first time fgets is called, so you can't use strlen on it. Besides, you don't want to know how long the string is; you want to pass the size of (hint) the LineStorage...
  6. What don't you have the option to do and why...

    What don't you have the option to do and why don't you have the option? Help us help you by being clear on what problem(s) you're facing.
  7. I'm not fluent in FORTRAN, but here's what I do...

    I'm not fluent in FORTRAN, but here's what I do know.

    The numbers on the left side are line numbers. Those can be used to jump to a different place in the code.

    FORTRAN's "DO" statement is like...
  8. Replies
    13
    Views
    353

    Ok, then if waitpid returns -1 (which doesn't...

    Ok, then if waitpid returns -1 (which doesn't necessarily mean "invalid child id"), that means you need to check errno for the error code (I probably should have said so in my previous post).

    You...
  9. Replies
    13
    Views
    353

    Check the return value of waitpid. That may give...

    Check the return value of waitpid. That may give you a clue what the problem is.

    Edit: Also, in the future, report what you expect to happen and what actually happens. Writing stuff like Must...
  10. Replies
    16
    Views
    706

    This is also incorrect: char c; c =...

    This is also incorrect:



    char c;

    c = fgetc(fp);

    fgetc() returns an int, not a char.
  11. Replies
    2
    Views
    333

    You don't even need an array for this problem....

    You don't even need an array for this problem. Here's how I interpret the problem statement:


    Read a number.
    If the number is less than or equal to zero, end.
    Print the running sum.
    Repeat...
  12. Replies
    53
    Views
    1,949

    Will It Shuffle? Or, why random comparators are...

    Will It Shuffle? Or, why random comparators are bad (in addition to being slow).
  13. Before you write code, write down detailed...

    Before you write code, write down detailed step-by-step instructions in English (or whatever language you're most comfortable with) on how you would accomplish the task. Think of it like a recipe: 1....
  14. Replies
    10
    Views
    395

    Replace "CPU" with "compiler" and you'd be...

    Replace "CPU" with "compiler" and you'd be correct. The "register" keyword is still recognized but doesn't have much (if any) effect anymore with modern optimizing compilers (they know which...
  15. Replies
    53
    Views
    1,949

    Incidentally, I mentioned using the Fisher-Yates...

    Incidentally, I mentioned using the Fisher-Yates algorithm in #4 and gave some code in #10 that does basically what you suggested. It seems like wolly either isn't reading or isn't understanding our...
  16. Replies
    4
    Views
    254

    Each node is linked to the previously-allocated...

    Each node is linked to the previously-allocated node, making all nodes accessible, so there's no memory leak (except at the very end of the program because the nodes in the linked list are not freed).
  17. Replies
    8
    Views
    1,649

    Also here: program for a tough problem....

    Also here: program for a tough problem.
  18. Replies
    4
    Views
    340

    By the way, this line: structure_variable =...

    By the way, this line:


    structure_variable = malloc (sizeof(structure_variable));

    should be:


    structure_variable = malloc (sizeof(*structure_variable));
  19. Replies
    6
    Views
    273

    C'mon, are you just trolling us now? I numbered...

    C'mon, are you just trolling us now? I numbered the rows for you.

    Your new code is correct, by the way.
  20. Replies
    6
    Views
    273

    The array has only 2 rows. How many rows are you...

    The array has only 2 rows. How many rows are you trying to fit in it? I counted 3:


    int array [2][3][4] =



    {
    { {1, 2, 3}, { 4, 5, 6} }, //...
  21. Replies
    53
    Views
    1,949

    You need to put something between the numbers if...

    You need to put something between the numbers if you want something between the numbers. It's up to you whether that's a space, newline, comma, or something else. Just add the number separator to the...
  22. Unlike Python, indentation means nothing to C....

    Unlike Python, indentation means nothing to C. Statements are grouped together (a "compound statement") with braces.
  23. Replies
    5
    Views
    409

    First things first: don't call main(). It's not...

    First things first: don't call main(). It's not necessary. If you want to return to the function that called your function, use a return statement.

    Second, what do you see if you print out the...
  24. Replies
    53
    Views
    1,949

    My take at it: void pick_n(int n, int out[])...

    My take at it:


    void pick_n(int n, int out[])
    {
    int pool[POOL_SIZE];
    for (int i = 0; i < POOL_SIZE; ++i) {
    pool[i] = i + 1;
    }
    int top = POOL_SIZE;
  25. Replies
    53
    Views
    1,949

    That description sounds like the Fisher-Yates...

    That description sounds like the Fisher-Yates shuffling algorithm, except it "shuffles" only 6 numbers and leaves the rest in place.

    So yes, it's a good start.
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4