Task: To create database of workers. The program also should to ouput worker’s info by
name and count average salary of all workers. When I try to compile this code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct worker {
char name[10];
int salary;
};
int main (void);
struct worker p1 = {"koko", 3400};
printf ("name=%s,salary=%d,p1,name,p1,salary");
return(0);
}
I get
./dz2.c:11:9: error: expected declaration specifiers or «...» before string constant
./dz2.c:12:1: error: expected identifier or «(» before «return»
./dz2.c:13:1: error: expected identifier or «(» before «}» token
I would be grateful for solution of this problem.
Combining the hints by others:
Note how
p1.nameandp1.salaryreference the fields insidep1(of typeworker)mainwas fixed