Search:

Type: Posts; User: christop

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    9
    Views
    159

    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);.
  2. 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...
  3. 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.
  4. 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...
  5. Replies
    13
    Views
    237

    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...
  6. Replies
    13
    Views
    237

    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...
  7. Replies
    16
    Views
    452

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

    This is also incorrect:



    char c;

    c = fgetc(fp);

    fgetc() returns an int, not a char.
  8. Replies
    2
    Views
    195

    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...
  9. Replies
    53
    Views
    1,319

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

    Will It Shuffle? Or, why random comparators are bad (in addition to being slow).
  10. 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....
  11. Replies
    10
    Views
    262

    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...
  12. Replies
    53
    Views
    1,319

    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...
  13. Replies
    4
    Views
    170

    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).
  14. Replies
    8
    Views
    875

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

    Also here: program for a tough problem.
  15. Replies
    4
    Views
    216

    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));
  16. Replies
    6
    Views
    163

    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.
  17. Replies
    6
    Views
    163

    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} }, //...
  18. Replies
    53
    Views
    1,319

    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...
  19. Unlike Python, indentation means nothing to C....

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

    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...
  21. Replies
    53
    Views
    1,319

    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;
  22. Replies
    53
    Views
    1,319

    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.
  23. Replies
    10
    Views
    355

    A compiler that doesn't initialize global...

    A compiler that doesn't initialize global variables is non-standard and should be used with care (or, if possible, discarded in favor of one that does follow the relevant standard(s)).
  24. Post your latest code and we can help.

    Post your latest code and we can help.
  25. Why would the texts not be synchronized? If you...

    Why would the texts not be synchronized? If you properly use a mutex in the threads to read lines from the stream, the threads will be synchronized.

    This is roughly how I'd do it:


    In the...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4