Search:

Type: Posts; User: flp1969

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    3
    Views
    137

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

    Is this right?

    Maybe:

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

    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.
  3. Replies
    10
    Views
    317

    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[]...
  4. Replies
    10
    Views
    317

    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].
  5. Replies
    6
    Views
    220

    (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
  6. Replies
    3
    Views
    193

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

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

    Don't need a loop:

    int nibbles = (1 << 4) - 1;
  8. Replies
    2
    Views
    135

    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" );
  9. You need to read the documentation, write some...

    You need to read the documentation, write some code, link with the libraries and voilą!
  10. 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...
  11. Replies
    11
    Views
    275

    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 )
  12. 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...
  13. Replies
    5
    Views
    193

    Pendulum...

    Pendulum
  14. 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!
  15. 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()...
  16. Replies
    1
    Views
    112

    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)) )
  17. rename(3) - Linux manpage...

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

    manpages and gdb are your friends... use them...
  19. Replies
    4
    Views
    172

    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...
  20. Replies
    1
    Views
    132

    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...
  21. Replies
    15
    Views
    503

    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).
  22. 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
  23. 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...
  24. Replies
    53
    Views
    1,317

    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');
  25. Replies
    53
    Views
    1,317

    Ahhhhh.... I keep forgeting about distribution....

    Ahhhhh.... I keep forgeting about distribution. Thanks. Those values are very clear to me now!
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4