Search:

Type: Posts; User: flp1969

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds; generated 50 minute(s) ago.

  1. 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...
  2. Replies
    15
    Views
    280

    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).
  3. 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
  4. 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...
  5. Replies
    43
    Views
    658

    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');
  6. Replies
    43
    Views
    658

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

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

    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...
  8. 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...
  9. Replies
    5
    Views
    191

    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...
  10. And you want to know how to do this using C...

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

    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.
  12. Replies
    5
    Views
    149

    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;
  13. Replies
    6
    Views
    149

    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.
  14. Replies
    5
    Views
    149

    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.
  15. Thread: Can't read int

    by flp1969
    Replies
    11
    Views
    299

    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;
  16. Replies
    43
    Views
    658

    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...
  17. Replies
    43
    Views
    658

    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...
  18. Replies
    43
    Views
    658

    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...
  19. Replies
    43
    Views
    658

    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...
  20. Replies
    43
    Views
    658

    Ahhhh... good one! I was really thinking 'john.c...

    Ahhhh... good one! I was really thinking 'john.c wouldn't miss this... why this thrid loop?!'... I didn't thought about sorted order! :)
  21. Replies
    43
    Views
    658

    From john.c code I would change just a little...

    From john.c code I would change just a little thing:

    void generate_ticket( int *ticket )
    {
    int used[HIGH_NUM + 1] = {0}; // initialized to all 0

    for ( int i = 0; i < NUM_TO_PICK; ++i )
    ...
  22. Thread: Can't read int

    by flp1969
    Replies
    11
    Views
    299

    Geez, I don't know, but maybe the error message...

    Geez, I don't know, but maybe the error message says everything you need to know...

    distance.cpp|6|error: expected ',' or ';' before 'int'
  23. Replies
    43
    Views
    658

    This is one way to do it, but since you need only...

    This is one way to do it, but since you need only 6 different values from 1 to 49, you can use a small array to "mark" those you already got and get another value if the corresponding index isn't...
  24. Replies
    43
    Views
    658

    Almost the same way you tried: n = (rand() %...

    Almost the same way you tried:

    n = (rand() % 49)+1;
    Taking the remainder of a division by 49 you'll get a value between 0 and 48 (inclusive), so you just need to add 1.

    "Random" doesn't mean...
  25. Thread: Writing a Code

    by flp1969
    Replies
    8
    Views
    241

    Really? You do know how to draw with pencil and...

    Really? You do know how to draw with pencil and paper, don't ya?
Results 1 to 25 of 499
Page 1 of 20 1 2 3 4