Search:

Type: Posts; User: jalex39

Search: Search took 0.00 seconds.

  1. Replies
    10
    Views
    6,885

    If no one one is eating initially and they both...

    If no one one is eating initially and they both excute the function take_ forks the first one will run test and see that neither person to his left or right meets the test so he will change his state...
  2. Replies
    10
    Views
    6,885

    The code is this-

    # define N 5
    # define LEFT (i+N-1)%N
    # define RIGHT (i+1)%N
    # define THINKING 0
    # define HUNGRY 1
    # define EATING 2
    typede int semaphore;
    int state[N];
    semaphore mutex = 1;
    semaphore...
  3. Replies
    10
    Views
    6,885

    Dining Philosopher question

    I am going to put this algorithm (attachment) in my code and however this code supposbly works and but it seems to me you could have a race condition if two adjacent philosophers try to aquire forks...
  4. Replies
    3
    Views
    61,980

    I understand my code works. That isn't the...

    I understand my code works. That isn't the problem. I guess I was just wondering why with my code does the reader still have access when the writter is writing sometimes it will say # of readers 1....
  5. Replies
    3
    Views
    61,980

    reader/writer problem using semaphores

    I am working on writting 2 programs, the first was using the algorithm provided to me which basically blocks the writter out as long as there are readers. That wasn't much of a problem. I then...
  6. Replies
    6
    Views
    1,675

    fscanf

    Here is my new code:


    #include <stdio.h>
    typedef struct {
    int avg_high_temp;
    int avg_low_temp;
    float avg_precip;
    int avg_wind_speed;
    } weather_t;
  7. Replies
    6
    Views
    1,675

    fgetc is a way to input a character at a time but...

    fgetc is a way to input a character at a time but the problem is the data is 3 ints and 1 float so how do I get mixed data in? I see that fread is for binary only- my mistake
  8. Replies
    6
    Views
    1,675

    Confused with pointers and structs

    I am writting a prohram that declares a struct with 3 ints and 1 float called weather_t. I must read the data in from a txt file for 12 months of data which would be 48 numbers. I need 2 functions...
  9. Replies
    1
    Views
    981

    Arrays and pointers

    If I am reading an array from a pointer, how can I get the first element of array: Right now the following code gets me reading an array of 500 intergers 100 at a time. What if I want to make the...
  10. Thread: Array problem

    by jalex39
    Replies
    5
    Views
    1,798

    Good

    Works great
  11. Thread: Array problem

    by jalex39
    Replies
    5
    Views
    1,798

    backwards

    int findmax(int array[], int size)
    {
    int max = 0;
    int i;

    for (i = 0; i < size; ++i)
    if (max > array[max])
    max = i;

    return max;
  12. Thread: Array problem

    by jalex39
    Replies
    5
    Views
    1,798

    backwatds

    When I run those # its backwards but if I use 1 3 5 it works
  13. Thread: Array problem

    by jalex39
    Replies
    5
    Views
    1,798

    Array problem

    I am writting a program that you enter intergers and am using a find minimum and max functions however I seem to be having a problem when I mix positive and negative # or use a zero. I think I am...
  14. Replies
    2
    Views
    1,075

    Got it!

    Got it right anyways thanks. Got my outer loop mixed with inner and got the function call correct.
  15. Replies
    2
    Views
    1,075

    Nested loop with function

    I have used this board once before and it was very helpful especially when I was blinded by the obvious so I thought I would ask to see if I have my loops back wards or incorrect. I am trying to...
  16. Replies
    6
    Views
    3,268

    Thanks

    I'll tell you sometimes you can understand the hardest part of something whether it be programing like this or anything in life but what seems to be the simpliest you can rack your brains. I...
  17. Replies
    6
    Views
    3,268

    Switch statement problem

    I am new to c and I am buliding a program with a buch of nested if and a switch statement based on my an input of a character from a scanf statement. the problem is when you ask the question what...
Results 1 to 17 of 17