Search:

Type: Posts; User: john.c

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. HANDLE hFind; WIN32_FIND_DATA FindFileData; ...

    HANDLE hFind;
    WIN32_FIND_DATA FindFileData;

    if((hFind = FindFirstFile("C:/some/folder/*.txt", &FindFileData)) != INVALID_HANDLE_VALUE){
    do{
    printf("%s\n", FindFileData.cFileName);...
  2. WTF?!

    WTF?!
  3. You turn on optimization with the -O flag. Try...

    You turn on optimization with the -O flag. Try -O2
    (That's the capital letter O.)
  4. Obviously he's running into a stack limit. And...

    Obviously he's running into a stack limit.
    And although tail call optimization is not guaranteed by the standard, any decent compiler will do it.
    But it is not done if you don't request...
  5. Since it's tail recursion, as long as it's...

    Since it's tail recursion, as long as it's optimized only a single stack frame would be used.
  6. Replies
    2
    Views
    149

    Just return the number of primes you found. ...

    Just return the number of primes you found.


    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <ctype.h>
    #include <math.h>

    int checkNumber(const char *word)
  7. Replies
    3
    Views
    150

    This is not correct if n is odd: 3*(n-1)*(n>>1)...

    This is not correct if n is odd:
    3*(n-1)*(n>>1) // or (n/2) instead of n>>1
    You need to multiply n*(n-1) first to ensure that the result is even before dividing by 2.


    Suppose n is 5:
    (5...
  8. Replies
    3
    Views
    150

    'a' must only go up to n - 1 since 'b' must start...

    'a' must only go up to n - 1 since 'b' must start at 'a + 1' but not go over 'n'. When 'a' is 1, there will be n - 1 'b's, when 'a' is n - 1 there will be 1 'b'. So the number of triples...
  9. Why are you bothering to dynamically allocate...

    Why are you bothering to dynamically allocate user? Just use an array.

    If you want to read from a file you need to pass the FILE* pointer to readFields and use fscanf.

    The "%s" format spec...
  10. If you don't need more than 128 bits there are...

    If you don't need more than 128 bits there are native 128-bit values available on 64-bit machines. The maximum for an unsigned 128-bit value is 340282366920938463463374607431768211455, which is about...
  11. @christop, You're right that the word "word" is...

    @christop, You're right that the word "word" is ambiguous. I just assumed it had it's "normal" meaning, but it could just mean "token" and the input could just be all numbers of the given form. I was...
  12. @christop, I think the input is a mixture of...

    @christop, I think the input is a mixture of words and numbers, e.g.:


    alpha beta 3,14 gamma 145,70 delta epsilon 0012,34 zeta

    Your variable n is unused in your code.

    There's no reason...
  13. Two problems. It makes your program dependent on...

    Two problems. It makes your program dependent on the user having that locale on their system. Also, using something like sscanf("%f",...) or strtod will allow a value without a fractional part (which...
  14. You need to maximize the warning level of your...

    You need to maximize the warning level of your compiler, pay attention to the warnings, and fix them. You have four unused variables in checkWord and you don't return anything from firstHalfNumber or...
  15. Ultra-Deep Field, obviously! Speaking of which,...

    Ultra-Deep Field, obviously!
    Speaking of which, why is this galaxy so yellow?
    https://upload.wikimedia.org/wikipedia/commons/e/e1/UDF423-SpiralGalaxy.jpg
  16. Replies
    8
    Views
    219

    You have no idea what you are talking about. But...

    You have no idea what you are talking about. But since you are convinced that you do, there's no point in my continuing the discussion. Good luck with that.
  17. Replies
    8
    Views
    219

    You are misunderstanding what "undefined...

    You are misunderstanding what "undefined behavior" means. It doesn't mean that it won't work or will definitely blow up in every implementation of the language. It just means that the standard itself...
  18. Replies
    19
    Views
    535

    You don't like Star Trek ?!?! 16291

    You don't like Star Trek ?!?!

    16291
  19. Replies
    16
    Views
    520

    16289 Don't make me resort to the double!...

    16289

    Don't make me resort to the double!
    (Read Salem's last post again! )
  20. Replies
    4
    Views
    353

    You say "could" leave out the terminating...

    You say "could" leave out the terminating semicolon, but you mean "must" leave out the terminating semicolon, or else the following will not work:


    if (b)
    WAIT_FOR_PERIPH(); // the...
  21. Replies
    19
    Views
    535

    16288

    16288
  22. Replies
    19
    Views
    535

    16287

    16287
  23. Replies
    19
    Views
    535

    16286

    16286
  24. Replies
    16
    Views
    520

    Yes.

    Yes.
  25. Replies
    5
    Views
    246

    Malcolm makes a very important point that I...

    Malcolm makes a very important point that I totally forgot about.
    It is "undefined behavior" to use a pointer to access memory that has been freed.
    In principle, anything can happen.
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4