Search:

Type: Posts; User: flp1969

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. static but global! It WILL keep the value between...

    static but global! It WILL keep the value between funcion calls.
  2. Because you are doing nothing. Here's an example:...

    Because you are doing nothing. Here's an example:


    #include <stdio.h>

    typedef void ( *action )( void );

    static int i = 0;
    static void pusty( void ) { i++; }
    // ^^^^^
  3. Replies
    4
    Views
    143

    Notice if you use the same pointer as an argument...

    Notice if you use the same pointer as an argument and return to realloc() call you can end up with a memory leakage if realloc() fails. It is wise to use different pointers. Your code, changed a...
  4. Thread: Pointer help

    by flp1969
    Replies
    27
    Views
    683

    ;)...

    ;)...
  5. Thread: Pointer help

    by flp1969
    Replies
    27
    Views
    683

    I'm getting there. Past my 5th decade... Here's a...

    I'm getting there. Past my 5th decade... Here's a good read about floating point if you are interested: Handbook of Floating Point arithmetic.

    []s
    Fred
  6. Thread: Pointer help

    by flp1969
    Replies
    27
    Views
    683

    Another example why floating point is another...

    Another example why floating point is another beast entirely:

    #include <stdio.h>

    #define SHOW_RESULT(c) \
    printf("[%s]\n", ((c))?"yes":"no")

    void testfp1 ( void )
    {
    double x = 1.2;
  7. Thread: Pointer help

    by flp1969
    Replies
    27
    Views
    683

    I must point out that, conceptually, using a loop...

    I must point out that, conceptually, using a loop instead of a bunch of calls to `pow()`, inline, is correct, but you are dealing with floating point here and floating point aren't exact...
  8. Replies
    12
    Views
    369

    Are you aware that C isn't Python, don't ya?

    Are you aware that C isn't Python, don't ya?
  9. Replies
    23
    Views
    1,098

    "pie" is undefined when calculating "diameter"....

    "pie" is undefined when calculating "diameter". Why calculate "radius" since you got it in scanf()?
    There is a M_PI constant in math.h. And you don't need stdlib.h.
  10. Replies
    23
    Views
    1,098

    If diameter is 2 times radius, 2 times PI times r...

    If diameter is 2 times radius, 2 times PI times r is the same as PI times diameter!

    And your code uses unecessary headers. Take a look at this simplification:

    // circ.c
    //
    // Compile with:...
  11. Replies
    3
    Views
    347

    Same tip as Salem's here... Use strtol() or...

    Same tip as Salem's here... Use strtol() or strtoul() functions. Observe that C99 also offers strtoll() and strtoull() for 'long long int's...
  12. Replies
    7
    Views
    435

    I am assuming the CGI processor spawns a process...

    I am assuming the CGI processor spawns a process and, in case of failure (disconnections, for example) it simply kills the process. I don't know how you are dealing with errors in your CGI...

    In...
  13. Replies
    7
    Views
    435

    What do you mean by 'large'? Several characters...

    What do you mean by 'large'? Several characters or loads of megabytes of them?
  14. Nice! ;)

    Nice! ;)
  15. Replies
    7
    Views
    547

    Change to Linux... I did it 17 years ago. No...

    Change to Linux... I did it 17 years ago. No regrets! :)
  16. Not that your strrev() is wrong, but I prefer to...

    Not that your strrev() is wrong, but I prefer to follow C's standard library philosophy and assume the arguments are correct and test/initialize them outside the funcion. I would implement strrev()...
  17. Replies
    3
    Views
    401

    Thanks, laserlight. I am using gcc 7.3 and 8.4...

    Thanks, laserlight.

    I am using gcc 7.3 and 8.4 (available in Ubuntu repos). Good to know they finally corrected this.

    []s
    Fred
  18. Replies
    3
    Views
    401

    Ahhhh... my locale setting: $ set | grep ^LC...

    Ahhhh... my locale setting:

    $ set | grep ^LC
    LC_ADDRESS=pt_BR.UTF-8
    LC_CTYPE=pt_BR.UTF-8
    LC_IDENTIFICATION=pt_BR.UTF-8
    LC_MEASUREMENT=pt_BR.UTF-8
    LC_MONETARY=pt_BR.UTF-8
    LC_NAME=pt_BR.UTF-8...
  19. Replies
    3
    Views
    401

    GCC not following C99+?

    Please, check my interpretation:

    ISO 9989:1999 and later says in topic 5.2.1.2:

    "An identifier, comment, string literal, character constant, or header name shall consist of a sequence of valid...
  20. Replies
    3
    Views
    385

    Yep.. use open() to get a file desciptor and... ...

    Yep.. use open() to get a file desciptor and...



    ... there is a special syscall to deal with devices: ioctl(), to send "commands" to control the device. Those commands are device dependent...
  21. Replies
    7
    Views
    343

    Problematic: #ifndef SIZE_END_BIT ...

    Problematic:



    #ifndef SIZE_END_BIT

    #define SIZE_END_BIT ~(SIZE_MAX>>1)

    #endif
  22. void dosomething( int *p ) { *p = 1; } void...

    void dosomething( int *p )
    { *p = 1; }

    void print( int *p )
    { printf( "%d\n", *p ); }

    int main ( void )
    {
    int x;
  23. Replies
    5
    Views
    638

    Ask yourself: "What is the origin for a 'child'...

    Ask yourself: "What is the origin for a 'child' window?" Is it the "desktop" or its parent window? And what if you have multiple monitors?
  24. Replies
    20
    Views
    680

    Even more: The pre-processor "code" below will...

    Even more: The pre-processor "code" below will always result in CHAR_BIT == 8:


    #ifndef CHAR_BIT
    #if ~0 << 8
    #define CHAR_BIT 8
    #elif ~0 << 7
    #define CHAR_BIT 7
    #elif ~0 << 6
    #define...
  25. Replies
    12
    Views
    507

    BMP file format - Wikipedia...

    BMP file format - Wikipedia
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4