mercredi 27 janvier 2016

can't run this code :: the code is about queue function that delete and add an item to an array

and this is the code ::

#include <stdio.h>

int Enqueue(int[],int);
int Dequeue(int[],int*);
int show(int[]);

int main (void)
{
    int q[]={1,2,3,4,5,6,7,8,9,10};
    //int n = sizeof(q)/sizeof(int);
    int l=0;
    int e=0;
    int d=0;

    printf("°°°°menu items°°°°\n");
    printf("1=enqueue\n");
    printf("2=dequeue\n");
    printf("3=show\n");
    printf("4=exit\n");
    scanf("%d",&l);
    while(l!=4)
    {
        if(l==1)
        {
            printf("plz enter the element you want to add : ");
            scanf("%d",&e);
            Enqueue(q,e);
        }
        else if(l==2)
        {
            Dequeue(q,&d);
        }
        else if(l==3)
        {
            show(q);
        }
        else
        {
            printf("plz enter a number from the menu");
        }
    }
    printf("bye bye");
}
int Enqueue(int q[],int e)
{
    int n = sizeof(q)/sizeof(int);

    e=q[n+1];
    return *q; 
}
int Dequeue(int q[],int d)
{
    int n = sizeof(q)/sizeof(int);

    q[1]=d;
    for (int i=1;i<n;i++)
    {
        q[i]=q[i-1];
    }
    printf("the deleted item is %d\n",d);
    return d;
}
int show(int q[])
{
    int n = sizeof(q)/sizeof(int);

    for (int i=0;i<n;i++)
    {
        printf("%d,",q[i]);
    }
}


the error is

:error #2120: Redeclaration of 'Dequeue', previously declared at C:\Users\mahmoud\Documents\Pelles C Projects\queue\queue.c(4); expected 'int function(int *, int *)' but found 'int function(int *, int)'.

Aucun commentaire:

Enregistrer un commentaire