I am not experienced in c programming.
I met a compile error like following
[gary@localhost hw10]$ gcc prog1.c
hw10.c:5: error: expected =, ,, ;, asm or __attribute__ before isLeap
I searched on google and found quite a few people have similar errors like me.
Someone comment this is because losing semicolon in struct definition or so.
I just check it out
but still not work.
More strange, if I use g++ to compile
it woks.
[gary@localhost hw10]$ g++ prog1.c
[gary@localhost hw10]$
But I think I am writing original c codes without any c++ syntax?
Here is the codes
prog1.c
Code:
#include <stdio.h>
#include "book.h"
#include "date.h"
bool isLeap(int year) {
if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)) return true;
else return false;
};
book.h
Code:
1 #ifndef BOOK_H
2 #define BOOK_H
3
4 enum Type {NOVEL, COMICS, MANUAL, TEXTBOOK};
5
6 struct Book{
7 char title[128];
8 enum Type type;
9 char ISBN[128];
10 char authors[128];
11 unsigned int importance;
12 };
13
14 #endif
date.h
Code:
1 #ifndef DATE_H
2 #define DATE_H
3
4 struct Date {
5 unsigned int year;
6 unsigned int month;
7 unsigned int day;
8 };
9
10 #endif
I would really apprecite for any comment..