Search:

Type: Posts; User: flp1969

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    10
    Views
    142

    And... also, you can use "perror()" to show you...

    And... also, you can use "perror()" to show you the error:


    f = fopen( "c:/file.txt", "w" );
    if ( f == NULL )
    {
    perror( "fopen" );
    return 1;
    }
  2. Replies
    10
    Views
    142

    Ahhh... even on Windows you can use '/', instead...

    Ahhh... even on Windows you can use '/', instead of '\\', in C, as in "c:/file.txt".
  3. Replies
    10
    Views
    142

    Do you have permission to create a file in the...

    Do you have permission to create a file in the root directory of drive C:? Open a prompt and try:

    c:\> echo "hello" > file.txt

    Are you using MSYS? Cygwin?
  4. Google (or Duckduck Go) is your friend: Completly...

    Google (or Duckduck Go) is your friend: Completly fair scheduler
  5. Thread: Word Counting

    by flp1969
    Replies
    10
    Views
    455

    Yep... just to demonstrate the point: "The word...

    Yep... just to demonstrate the point: "The word 'word' is the word.", if not properly dealt with, will give one word of each "The", "the", "'word'", "word" and "word." and "is".
  6. Thread: Word Counting

    by flp1969
    Replies
    10
    Views
    455

    What is a 'word' in this context? Take your text,...

    What is a 'word' in this context? Take your text, above, as an example: punctuation will be considered as part of the 'word' or your files are only lists of words?

    A better approach would be to...
  7. An interesting bug on CLANG (at least in version 11)

    #include <stdio.h>

    static void (*ptr)(void) = NULL;

    void f(void) { puts( "hello" ); }

    void g(void) { ptr = f; }

    int main( void ) { ptr(); }
  8. Replies
    9
    Views
    328

    An interesting bug on GCC 9 and above

    #include <stdio.h>

    int main ( void )
    {
    unsigned int a;
    unsigned int b;
    unsigned int c;

    c = 0;
    for ( a = 0; a < 10; a++ )
  9. Replies
    7
    Views
    268

    And... let's say the first equation is correct......

    And... let's say the first equation is correct... So, you want to calculate a FUNCTION, isn't it? Why not to code a function f()?


    double f(double t)
    {
    return...
  10. Replies
    7
    Views
    268

    Are you sure the equation is correct? 16382

    Are you sure the equation is correct?

    16382
  11. Replies
    20
    Views
    722

    Tip, works with GCC, CLANG and Intel C++ Compiler...

    Tip, works with GCC, CLANG and Intel C++ Compiler (but I'm not sure of __attribute__ syntax there... probably __declspec):



    void cleanup_str( char **p ) { free( *p ); }
    ...
    /* Some function...
  12. Replies
    3
    Views
    231

    Read the code again... the result of memcmp is...

    Read the code again... the result of memcmp is being asserted, not if sizeof(data_in)==0
  13. The compiler must know about the identifiers it...

    The compiler must know about the identifiers it is using... So, you can do:

    // file1.c
    int x = 10;

    // main.c

    // The compiler must know that 'x' exists elsewhere!
    extern int x;
  14. Replies
    37
    Views
    2,068

    Here's how: 16365

    Here's how:
    16365
  15. Ahhhh... of course: 16363 I just don't know if...

    Ahhhh... of course:
    16363
    I just don't know if double precision is sufficient to hold factorials of "big" numbers (like INT_MAX-2).

    Testing here: 171 will cause overflow! 1755! overflows for...
  16. You do notice that your function is not well...

    You do notice that your function is not well behaved for some values of x, don't you?
    16361
    And it's worse: The denominator isn't continuous for a lot of values (if considering x integer, it is...
  17. Replies
    11
    Views
    764

    rand() is a pseudo random number generator. It...

    rand() is a pseudo random number generator. It isn't really random, just appears to be. It depends on the initial value seeded to the algorithm. If this value is 12, rand() will always give you the...
  18. If the code is too complex for you to fix for...

    If the code is too complex for you to fix for Windows (I don't do Windows in 14 years), then forget it... The explanation in post #9 should be sufficient.

    And, yet... you forget, in both codes, to...
  19. In essence it is the same thing. I've only notice...

    In essence it is the same thing. I've only notice that any comparison results in 0 or 1 (not other values)... The if:


    bin = n & 0x80; // isolate bit 7.
    if ( bin == 1)
    s[i] = '1';
    else
    ...
  20. Another thing: All numeric representations in a...

    Another thing: All numeric representations in a computer are binary. When you do

    int x = 10;
    This "decimal" 10 is encoded in binary and put in memory (or register) as a binary value. So, you can...
  21. Replies
    3
    Views
    714

    General rule: for is only a clever way to write...

    General rule: for is only a clever way to write while loops. With your example:

    for (int i = 0, j = n - 1; i < j; i++, j--)
    doSomething();
    Is the same as:

    /* block, because i and j are...
  22. As hamster_nz said, there is a problem of...

    As hamster_nz said, there is a problem of rounding when using floating point, specially with pow(), since the power is calculated as:
    16359
    The natural logarithm is approximated, and the...
  23. Neither do I... It is a valid point, since MinGW...

    Neither do I... It is a valid point, since MinGW uses MSVCRT??.dll and maybe pow() is implemented there.
  24. This is also my suspicion... Since x^y (^ as...

    This is also my suspicion... Since x^y (^ as potency) is calculated as e^(y*ln(x)) and, maybe, MinGW implementation of pow() can be a little bit wrong (there's a final approximation that need to be...
  25. I have my suspicions: Please compile and run this...

    I have my suspicions: Please compile and run this program and post what is printed (on Windows) -- don't forget to link the libm library.

    /* test.c */

    #include <stdio.h>
    #include <math.h>
    ...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4