Search:

Type: Posts; User: Salem

Page 1 of 20 1 2 3 4

Search: Search took 0.34 seconds; generated 59 minute(s) ago.

  1. Thread: FIFO Queue

    by Salem
    Replies
    21
    Views
    537

    > ShowEnqueue(struct Queue &q) Look at all the...

    > ShowEnqueue(struct Queue &q)
    Look at all the other calls, does this look like a call?

    > // what need to print value of Enqueue ?
    I'm not sure you're even trying.
    No more drip feeding, make...
  2. Thread: FIFO Queue

    by Salem
    Replies
    21
    Views
    537

    #define CAPACITY 10 #define True 1 ...

    #define CAPACITY 10
    #define True 1

    struct Queue {
    int data[CAPACITY];
    int front;
    int back;
    int size;
    };
  3. Thread: FIFO Queue

    by Salem
    Replies
    21
    Views
    537

    Your size is the size of the array, which is...

    Your size is the size of the array, which is constant.

    You want the number of elements presently stored in the queue.
    In rather simplistic terms, this is just front - back.
  4. Thread: FIFO Queue

    by Salem
    Replies
    21
    Views
    537

    Enqueue is q->data[q->front++] = data; ...

    Enqueue is
    q->data[q->front++] = data;

    Dequeue is
    return q->data[q->back++];

    Well that's the essential part, you need to
    - check the queue isn't full when adding
    - check the queue isn't...
  5. Thread: FIFO Queue

    by Salem
    Replies
    21
    Views
    537

    This should be struct Queue q; ...

    This should be


    struct Queue q;
    queueInit(&q);
  6. Replies
    3
    Views
    214

    Like this perhaps. #include ...

    Like this perhaps.


    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>

    char *changeString(char *str, size_t size);

    int main()
  7. Thread: FIFO Queue

    by Salem
    Replies
    21
    Views
    537

    I would suggest you start with a simple finite...

    I would suggest you start with a simple finite array version you can prototype with to make sure everything works as you expect.


    struct Queue {
    int data[10];
    int front;
    int back;
    };
    ...
  8. Replies
    1
    Views
    158

    List traversal. struct Node* temp = Head;...

    List traversal.


    struct Node* temp = Head;
    while ( temp ) {
    // do something with the current node
    printf("This=%p Next=%p Data=%d\n",
    (void*)temp, (void*)temp->Next, temp->X );

    ...
  9. > I don't know what it does but I commented it...

    > I don't know what it does but I commented it and the code works the same way, what it does exactly ?
    Read the M$ manual page for it.

    > Why the first while loop doesn't break or stop, I put a...
  10. Figures - I was wondering how someone could write...

    Figures - I was wondering how someone could write multiple threaded code and not have a clue how to fix a simple printf.
    Calculate Pi with Leibniz formula using pthread library (as part of C course)...
  11. Replies
    21
    Views
    674

    Well that was interesting. #include...

    Well that was interesting.


    #include <stdio.h>
    #include <stdlib.h>
    #include <limits.h>
    #include <math.h>
    #include <unistd.h>
    #include <pthread.h>
  12. > strtok isn't helpful in this kind of situation...

    > strtok isn't helpful in this kind of situation that is why I worked on this piece of code.
    How so?

    You can pass multiple tokens to strtok.


    #include <stdio.h>
    #include <string.h>
    int main...
  13. > printf("\nThe value of Pi = %f\n", threads,...

    > printf("\nThe value of Pi = %f\n", threads, pi);
    You have two parameters, but only one % conversion in the format string.

    Maybe


    printf("\nThe value of Pi = %f\n", pi);
    or
  14. Replies
    21
    Views
    674

    Not without seeing your current code. Sieve of...

    Not without seeing your current code.

    Sieve of Eratosthenes - Wikipedia
    "Sieve of Eratosthenes: algorithm steps for primes below 121 (including optimization of starting from prime's square)."
  15. > I don't know what it's actually, a struct or a...

    > I don't know what it's actually, a struct or a function,
    It's quite obviously a function.
  16. Replies
    6
    Views
    376

    > I'm not sure how critical this part may be. ...

    > I'm not sure how critical this part may be.
    Very - Setting up the initial hardware environment is a delicate operation, especially when that hardware can also generate interrupts.
    Not at all -...
  17. One or more of these. Using Timer Queues - Win32...

    One or more of these.
    Using Timer Queues - Win32 apps | Microsoft Docs
    Using Timers - Win32 apps | Microsoft Docs
    About Timers - Win32 apps | Microsoft Docs
    SetTimer function (winuser.h) - Win32...
  18. Thread: if...else ERROR

    by Salem
    Replies
    2
    Views
    234

    > city.lat_dir = 'INVALID!'; Use strcpy to copy...

    > city.lat_dir = 'INVALID!';
    Use strcpy to copy strings to arrays.

    strcpy(city.lat_dir,"INVALID");
  19. Replies
    21
    Views
    674

    You only need 1 bit per random number (you're...

    You only need 1 bit per random number (you're only storing a true/false).
    So the whole RAND_MAX range would only need 256MB of memory.
    But the lookup is O(1) when you're done.

    By contrast, an...
  20. Replies
    21
    Views
    674

    > 100M numbers is only 5% of the range of a...

    > 100M numbers is only 5% of the range of a 32-bit RAND_MAX.
    RAND_MAX is say 2147483647, which is 20x bigger than 100M, hence 5%

    > If I make a pre-computed sieve table, isn't that cheating?
    Only...
  21. Thread: mfc c++

    by Salem
    Replies
    3
    Views
    212

    Your picture doesn't work, and you obviously mean...

    Your picture doesn't work, and you obviously mean something else than "recover".
  22. Replies
    5
    Views
    244

    So how does this differ from std::vector or...

    So how does this differ from std::vector or std::array ?

    I see your readme has "If you wanna use type std::string it won't work , so instead use char*"
    Does that go for anything else which isn't...
  23. Thread: Pointers stuff

    by Salem
    Replies
    4
    Views
    333

    Yes, moved.

    Yes, moved.
  24. Thread: Pointers stuff

    by Salem
    Replies
    4
    Views
    333

    There are two (or 3) things wrong with your rev...

    There are two (or 3) things wrong with your rev function.
    1. Your local reverse array is too short (there is no room for a \0)
    2. Your local array goes out of scope when you return. You don't...
  25. So what's == if it's not a comparison operator?

    So what's == if it's not a comparison operator?
Results 1 to 25 of 495
Page 1 of 20 1 2 3 4