Categories
Mastering Development

Error: Expected “;” or “,” or “)” before numeric constant

So, a friend of mine send me his code for a project and asked me to look at it but i cant find where the problem is.
Here is the code for his main :

#include"queue.h" //Importing libraries
#include<string.h>
#include"stack.h"
void main(int argc, char** argv[]){ //Recognition of arguments from terminal
int i;
printf("\nYou gave command line: %s\n",argv[1]);
int y;
printf("Give number of wagons"); //Recognition of number of wagons from user
scanf("%d",&y);
STACK *A; //Declaring of Queues and Stacks
STACK *B;
QUEUE D;
QUEUE DD;
//Initialization of Stacks
A=create();
B=create();
makeempty(&D);
makeempty(&DD);
int j,x;

printf("Give the row as it is\n");
for (i=0;i<y;i++){ //Filling D Queue(Original layout)
  printf("Give element of row");
  scanf("%d",&x);
  enqueue(x,&D); 
}//for

printf("Give the row as it should be\n");
for (i=0;i<y;i++){ //Filling DD Queue(Final layout)
  printf("Give element of row");
  scanf("%d",&x);
  enqueue(x,&DD); 
}//for

 push(B,664); //Pushing a ramdon element in stack B, so it won't be empty



j=0;
for (i=0;i<y;i++){
  if (top(B)==Top(&DD)){ //Checking top element of B with DD 
    printf("Moving wagon %d from line B to the left\n", top(B));        
    push(A,top(B)); //If it's the same, then move from B to A
    dequeue(&DD); //Decreasing DD Queue and stack B
    pop(B);
    j++; //Increase change counter
    }//if  
   
  else if (Top(&D)==Top(&DD)){ //Checking topD with topDD
    printf("Moving wagon %d from right to the left through A\n", Top(&D));  
    push(A,Top(&D)); //If same, then move from D to A
    dequeue(&DD);  //Decreasing DD Queue and D Queue
    dequeue(&D);
    j++; //Increase change counter
    }//if
  else{
   printf("Moving wagon %d from left to B\n", Top(&D));
   push(B,Top(&D)); //Otherwise, moving topD to topB
   dequeue(&D); //Decreasing D Queue
  }//else

}//for

for (i=j; i<y; i++){ //At second for, if it's possible I put anything left from B to A
    if (top(B)==Top(&DD)){
       printf("Moving wagon %d from  B to the left\n",top(B));
       push(A,top(B));
       pop(B);
       dequeue(&DD);
       }//if

    else if (Top(&D)==Top(&DD)){ //Checking topD with topDD 
    printf("Moving wagon %d from right to the left through A\n", Top(&D));  
    push(A,Top(&D)); //If same, then move from D to A   
    dequeue(&DD);  //Decreasing DD Queue and D Queue
    dequeue(&D);
    }//if
    
    else {
      printf("Error, this layout is not possible to be done\n");
      exit(-1); //If it's no possible to move from B to A, means that this layout cannot be done
    }//else

}//for

printf("The layout has been done.\n");
//Otherwise, this means that the layout has been done


}//main

and this is his queue.h

#ifndef HEADER_FILE
#define HEADER_FILE

#define n 40
//to struct queue
typedef struct{
    int list[n];
    int front;

    int rear;

}QUEUE;

//ta prototipa ton synartiseon gia ta queues
void enqueue(int x,QUEUE *Q);

int isempty(QUEUE *Q);

void makeempty(QUEUE *Q);

void dequeue(QUEUE *Q);

int Top(QUEUE *Q);

#endif

this is his queue.c:

#include"queue.h"

void enqueue(int x,QUEUE *Q){
    if (Q->rear<n){
        Q->list[Q->rear]=x;
        Q->rear++;
    }

}

int isempty(QUEUE *Q){
    return(Q->front==Q->rear);
}

void makeempty(QUEUE *Q){
    Q->front=0;
    Q->rear=0;
}

void dequeue(QUEUE *Q){
    if (!isempty(Q) && ((Q->front)<(Q->rear))){
        Q->front++;

    }
}

int Top(QUEUE *Q){
    if (!isempty(Q)){
        return (Q->list[Q->front]);
    }
    return 0;
}

the problem is highlighted in line 3 in queue.h where the error is :
Error: Expected ";" or "," or ")" before numeric constant.
edit: line 4 not line 3 sorry

Leave a Reply

Your email address will not be published. Required fields are marked *