-7

This is a program to read & display a students data (name , date of birth, gpa). I do not understand where is the problem, it displays syntax error before } token(line 14) & syntax error before struct (line 8). Any good advice? Thank you in advance.

  #include<stdio.h>
  #include<stdlib.h>
  void main ()

  typeof struct
  {
    char name[10] ;
    date DOB ;
    float gpa;

  }
  student ;

  typeof struct
  {
      int day , month , year ;
  }
  date;

  printf("enter number of students n ");
  scanf("%d",&n);

  for(i=0;i<n;i++)
  {
     printf("enter student % data(name , date of birth & gpa )");
     scanf("%s%d%lf",i+1, &a[i].name , &a[i].DOB.day, &a[i].DOB.month,                   &a[i].DOB.year , &a[i].gpa);
  }

  for(i=0;i<n;i++)
  {
     printf("nmae : %s\t date of birth : %d \t gpa : %lf\t",i+1, a[i].name ,     a[i].DOB ,  a[i].gpa);
  }
Cœur
  • 37,241
  • 25
  • 195
  • 267
  • 3
    You can't put a `typedef` (not `typeof`!) right after `void main()`. Put the `typedef` declarations before it. It's basic C program syntax. For advice, I would suggest working through a C tutorial. – lurker Dec 24 '13 at 00:35
  • Please mark the erroneous lines, counting all the empty ones is annoying. – Kninnug Dec 24 '13 at 00:35
  • 1
    In addition `main` should return an `int` having `void` as argument or `int argc, char *argv[]`, as you can read [here](http://stackoverflow.com/questions/5020362/declare-main-prototype) (see the accepted answer). – pzaenger Dec 24 '13 at 00:43

1 Answers1

3

You should define your structures outside of the body of main.

Also, typeof is not the C construct you want to use when defining a structure. Maybe you wanted typedef?

And your main lacks the enclosing {, }.

Mihai Maruseac
  • 20,967
  • 7
  • 57
  • 109