Hi, I am having programming issues with C. I have not used C in quite a long time, and I am trying to refresh my practice of C for I need to use it for work. The program that I am having compiling issues with makes use of derived data type and structure. It is very simple, and taken directly from a textbook (see code at the end of post), however, I am getting the following compiling errors:
test.c:4: error: expected ) before . token
test.c:5: error: expected =, ,, ;, asm or __attribute__ before . token
test.c:6: error: expected declaration specifiers or ... before string constant
test.c:6: error: expected declaration specifiers or ... before student_1
test.c:6: error: expected declaration specifiers or ... before student_1
test.c:6: warning: data definition has no type or storage class
test.c:6: error: conflicting types for printf
test.c:6: note: a parameter list with an ellipsis cant match an empty parameter name list declaration
I use gcc compiler.
Any idea what is wrong with my code??
Thanks for any help you can provide.
Sincerely,
Yann
CODE:
(header file)
Code:
#include <stdio.h>
#include <stdlib.h>
typedef struct {
char name[20];
int age;
int course_code;
int course_year;
long int student_id;
} Student;
(main file)
Code:
#include "header.h"
Student student_1;
strcpy(student_1.name, "Smith, Bert");
student_1.age = 17;
printf("student name %s, age %d ", student_1.name, student_1.age);