Search:

Type: Posts; User: flp1969

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. 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!
  2. 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()...
  3. Replies
    1
    Views
    70

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

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

    manpages and gdb are your friends... use them...
  6. Replies
    4
    Views
    123

    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...
  7. 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...
  8. Replies
    15
    Views
    320

    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).
  9. 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
  10. 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...
  11. Replies
    43
    Views
    732

    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');
  12. Replies
    43
    Views
    732

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

    Ahhhhh.... I keep forgeting about distribution. Thanks. Those values are very clear to me now!
  13. Replies
    43
    Views
    732

    How did you got this values? Ok... usually rand()...

    How did you got this values? Ok... usually rand() implement LCG, that is less random in the lower bits, but being agnostic about the algorithm, I don't see why a random 32 bits value can generate...
  14. If you have an integer type and divide by 2,...

    If you have an integer type and divide by 2, you'll get an integer value (even if this value is converted, later, to a floating point type), so:

    sqt = p/2;
    will always result in an integer. The...
  15. Replies
    5
    Views
    210

    One tip not related to your problem: Don't use...

    One tip not related to your problem: Don't use 'system("cls");'. It is DOS/Windows specific and dangerous (what if someone put a cls.exe in the directory with a virus?)...

    Here's a clearscreen.c...
  16. And you want to know how to do this using C...

    And you want to know how to do this using C language?
  17. Replies
    6
    Views
    170

    Me too... I prefer to allocate the buffer myself,...

    Me too... I prefer to allocate the buffer myself, in the heap, and keep the stack as short as possible.
  18. Replies
    5
    Views
    170

    Your code, changed a little: #include...

    Your code, changed a little:

    #include <stdio.h>
    #include <stdlib.h> // EXIT_SUCCESS and EXIT_FAILURE are defined here.

    int main ( void )
    {
    size_t i, size;
    int largest;
  19. Replies
    6
    Views
    170

    Again, defining an array of variable length using...

    Again, defining an array of variable length using an uninitialized 'size' is WRONG.
    And the warnings are correct.
  20. Replies
    5
    Views
    170

    You are defining an array with variable length...

    You are defining an array with variable length BEFORE initializing 'size';
    In your final loop you are getting the SMALLEST, not the LARGEST.
  21. Thread: Can't read int

    by flp1969
    Replies
    11
    Views
    338

    You need to learn how to read: #include...

    You need to learn how to read:


    #include <iostream>
    #include <cmath>

    using namespace std;

    const double g = 9.8;
  22. Replies
    43
    Views
    732

    And, if you want a more "random" seed, if RDRAND...

    And, if you want a more "random" seed, if RDRAND is not available, you can change SRAND_() like this:

    static void SRAND_(void)
    {
    int fd;
    unsigned int rnd;
    ssize_t size;

    if ( ( fd...
  23. Replies
    43
    Views
    732

    Just to be compliant with Intel recomendations,...

    Just to be compliant with Intel recomendations, the RAND_() function should be like this:

    static unsigned int RAND_( void )
    {
    unsigned int r;
    int retries;

    // Intel recomends...
  24. Replies
    43
    Views
    732

    Here's the excellent code from john.c, but using...

    Here's the excellent code from john.c, but using the parameters for the problem (tickets with 6 numbers from 1 to 49) and a "trully random number generator", if your processor is Intel or AMD and...
  25. Replies
    43
    Views
    732

    john.c already explained this, below... in the...

    john.c already explained this, below... in the first version of this routine the 'used' array was declared with 50 elements because he wasn't using used[0].

    So you can see a similar approach, but...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4