2

Here is the part of the code that isnt working for me.I am declaring a pointer to a structure and I try to use it on a function,although c says that it cant convert main person to person.

void display (char *s2,FILE *f1,int max);
void insert (FILE  *f1, struct person *p1);
void deletestring (FILE *f1,FILE *f2,char *s2,char *s1,char *file1,char *file2,int max);
void edit (FILE *f1,FILE *f2,char *s2,char *s1,char *file1,char *file2,struct person *p1,int max);
int main ()
{
    char s1[MAX],s2[MAX];
    FILE *f2,*f1;
    struct person
    {
           char id[MIN];
           char emer[MIN];
           char mbiemer[MIN];
           };
    struct person p1;
    struct person *pp1;
    pp1 = &p1;
    char *file1 = "f1.txt";
    char *file2 = "f2.txt";

    int zgjedhja=1;
    printf("Programi funksionon sipas shpjegimit \n :");
    printf("Shtypni 1 per te shtuar nje person \n Shtypni 2 per te ndryshuar informacionin e nje personi \n Shtypni 3 per te shfaqur te dhenat \n Shtypni 4 per te fshire nje person \n Shtypni -1 per te dale nga programi \n ");

    while (zgjedhja != -1 )
    {
          printf("Jepni zgjedhjen tuaj \n ");
          scanf(" %d " , & zgjedhja );
          switch (zgjedhja)
          {
                 case 1:      
                 f1=fopen(file1,"a");
                 insert (f1,pp1);

1 Answer 1

3

The type struct person has main scope, so it won't have the same meaning in insert. In fact, a structure type whose members have not been specified is known as an incomplete type. To remove this error, declare your structure outside of your function.

struct person
{
    /* ... */
};

/* Function declarations. */

int main (void)
{
    /* ... */
}
Sign up to request clarification or add additional context in comments.

1 Comment

Well that worked nicely.Thanks.7 Min until you get the correct answer award :P.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.