0

I am really bad at C and now I'm trying to compile this code but keeps failing it. I think function itself does not have any problem (I test it separately and works well) but I got "expected expression":

error: expected expression

_Bool isRunning = checkRunning(i, n, state);

I think function returns nothing. My guess is that I put function in wrong place, but I don't know how to fix it.

This is my function:

_Bool checkRunning(int currProcess, int n, int state[])
{
      for (int i = 0; i < n; i++)
      {
          if(i == currProcess)
          {
             continue;
           }
          if(state[i] == 1){
            return true;
          }
      }
  return false;
}

and the way that I call this function is that

int main(){
 ```other expression```
 fifo(n, state, process_times);
}

and Within fifo(n, state, process_times) function, I call like this

void fifo(int n, int state[], int process_times[]){
// Run while loop while all processes are not terminated
_Bool isTerminated = checkAllTerminated(n, state);
while(!isTerminated){
    // Loop over state of all processes
    for (int i = 0; i < n; i++)
    {
        int next_state = state[i];
        switch(state[i])
        {
            //When process is ready
            case 0:
            //Check other process is running
            _Bool isRunning = checkRunning(i, n, state);
            if(!isRunning){
            ```other expression````

I declared each function in this order

_Bool checkAllTerminated(int n, int state[])

_Bool checkRunning(int currProcess, int n, int state[])

void fifo(int n, int state[], int process_times[])

int main()

0 Answers0