Search:

Type: Posts; User: flp1969

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    4
    Views
    140

    What test didn't pass? And you should ask...

    What test didn't pass?

    And you should ask yourself if, for example, 0.5 is even or odd.
    It doesn't make any sense asking if a fraction, resulting in a non integer value, is even or odd...
    ...
  2. Replies
    3
    Views
    149

    Is this right? Maybe: int nfields =...

    Is this right?

    Maybe:

    int nfields = sscanf(line, "%d %d %d %d", &d1, &n1, &d2, &n2);
  3. Replies
    3
    Views
    194

    Another tip, using only ISO functions from...

    Another tip, using only ISO functions from string.h:


    char *foo( char *s )
    {
    char *p;
    char tmp;
    ssize_t size;

    // get the size of final string.
  4. Replies
    10
    Views
    327

    I prefer to deal with pointers: #define...

    I prefer to deal with pointers:


    #define ARRAY_TEMS(a) (sizeof a / sizeof a[0])
    int x[] = { 1, 2, 3, 4 };
    int y[] = { 6, 7, 8, 9 10 };
    int z[9]; // must have enough space to both x[] and y[]...
  5. Replies
    10
    Views
    327

    Well... it depends... int a[4], *p = &a[2];...

    Well... it depends...

    int a[4], *p = &a[2];
    p[-2] = 0; // valid!. same as a[0].
  6. Replies
    6
    Views
    234

    (1

    (1 << 4) in binary: 0b10000

    It is 00001 shifted left 4 bits.

    0b10000 - 1 = 0b1111 (all 4 bits set).

    Let's say you want only 1 bit set:

    (1 << 1) - 1 = 0b0010 - 1 = 0b0001
  7. Replies
    3
    Views
    205

    Please, put srand(time(NULL)) outside the loop....

    Please, put srand(time(NULL)) outside the loop. Inside you risk not getting "random" values with rand(). The seed must be provided only once in your program.
  8. Replies
    6
    Views
    234

    Don't need a loop: int nibbles = (1

    Don't need a loop:

    int nibbles = (1 << 4) - 1;
  9. Replies
    2
    Views
    146

    Something like this? static void...

    Something like this?

    static void do_nothing(int sig) {}
    ...
    signal( SIGALRM, do_nothing );

    alarm(3);
    errno = 0;
    write( ... );
    if ( errno == EINTR ) puts( "timedout" );
  10. You need to read the documentation, write some...

    You need to read the documentation, write some code, link with the libraries and voilą!
  11. For Linux/FreeBSD I recomend ALSA and ffmpeg (lav...

    For Linux/FreeBSD I recomend ALSA and ffmpeg (lav libraries)... You can try to use SDL sound libraries as well...
  12. Replies
    11
    Views
    294

    One little thing, thou... this: #include...

    One little thing, thou... this:

    #include <stdio.h>

    int main( void )
    {
    int number = -987;
    int reverse = 0;

    while ( number > 0 )
  13. Trivial, but your code has several errors...

    Trivial, but your code has several errors (exemple: shifting a signed integer left) and since this is a C language programming forum, it is completely wrong...

    Here's a more direct way to convert...
  14. Replies
    5
    Views
    207

    Pendulum...

    Pendulum
  15. As Salem told you, this code is an old code for...

    As Salem told you, this code is an old code for MS-DOS and won't work on WINDOWS!
  16. The compiled final code isn't just YOUR code....

    The compiled final code isn't just YOUR code. There is an initialization and finalization codes as well. This 'initialization' code calls main(), in console applications, but Windows calls WinMain()...
  17. Replies
    1
    Views
    117

    Nope: #define clear_bit( v, bit ) ( (v) &...

    Nope:


    #define clear_bit( v, bit ) ( (v) & ~(1U << (bit)) )
    #define set_bit( v, bit ) ( (v) | (1U << (bit)) )
    #define toggle_bit( v, bit ) ( (v) ^ (1U << (bit)) )
  18. rename(3) - Linux manpage...

    rename(3) - Linux manpage
  19. manpages and gdb are your friends... use them...

    manpages and gdb are your friends... use them...
  20. Replies
    4
    Views
    182

    Or, declare a pointer to a function and...

    Or, declare a pointer to a function and initialize this pointer to the static function:


    /* module1.c */
    static int f( int x ) { return x + x; } // visible to this module only;
    int...
  21. Replies
    1
    Views
    134

    1- A pointer variable holds an address which...

    1- A pointer variable holds an address which points to a single memory location. malloc() alocates (reserves) a block of memory and returns the address of the first byte;

    2- Yes... The NULL...
  22. Replies
    15
    Views
    515

    Nope... 'ą' is UTF+00E0 and 0xE0 is 224, not 133....

    Nope... 'ą' is UTF+00E0 and 0xE0 is 224, not 133. What you are asking for is the code of 'ą' using WINDOWS-1252 (probably) codepage (or a variation of ISO-8859-1 or Latin-1).
  23. Did you search on MSDN? Here's an example (not...

    Did you search on MSDN? Here's an example (not quite what you want, but it is a start): Capturing an image
  24. My view of pointers and memory: In a very...

    My view of pointers and memory:

    In a very simple way, when you declare a variable you are asking the compiler to reserve enough space to hold the value in the size of that type. So, "int x;", a...
  25. Replies
    53
    Views
    1,352

    for ( i = 0; i < sizeof lotto / sizeof lotto[0];...

    for ( i = 0; i < sizeof lotto / sizeof lotto[0]; i++)
    printf( "%d ", lotto[i] );
    putchar('\n');
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4