[ create a new paste ] login | about

Link: http://codepad.org/eXFDFmKn    [ raw code | output | fork ]

C, pasted on Dec 20:
#include<stdio.h>



struct NhanVien {
	char * ten;
	char * gioiTinh;
	float gioLam;
	float luongGio;
	float thucLinh;
};

NhanVien * nhapNhanVien(int );
void xuatNhanVien(int , NhanVien );

int main(){
	int n;
	NhanVien * NV;
	printf("Ban muon nhap bao nhieu nhan vien? ");
	scanf("%d",&n);
	NV = nhapNhanVien(n);
	printf("Danh Sach Nhan Vien Vua Nhap\nTen\tGT\tGL\tLG\tThuc Linh\n");
	for(int i = 0; i < n ; i++){
		xuatNhanVien(i,NV);
	//	printf("%s\t%s\t%.2f\t%.2f\t%.2f",&(*(NV+i)).ten,&(*(NV+i)).gioiTinh,(*(NV+i)).gioLam,(*(NV+i)).luongGio,(*(NV+i)).thucLinh);

	}
}

NhanVien * nhapNhanVien(int n){
	NhanVien * nhanvien = new NhanVien[n];
	for(int i = 0 ; i < n ; i++){
		printf("Nhap ten nhan vien thu %d: ", i+1);
		fflush(stdin);
		gets(nhanvien[i].ten);
		printf("Nhap gioi tinh nhan vien thu %d: ", i+1);
		scanf("%s", &nhanvien[i].gioiTinh);
		printf("Gio lam nhan vien thu %d: ", i+1);
		scanf("%f", &nhanvien[i].gioLam);
		printf("Luong gio nhan vien thu %d: ", i+1);
		scanf("%f", &nhanvien[i].luongGio);
		nhanvien[i].thucLinh = nhanvien[i].gioLam * nhanvien[i].luongGio;
	}
	return nhanvien;
}

void xuatNhanVien(int i, NhanVien * NV){
	printf("%s\t%s\t%.2f\t%.2f\t%.2f",&(*(NV+i)).ten,&(*(NV+i)).gioiTinh,(*(NV+i)).gioLam,(*(NV+i)).luongGio,(*(NV+i)).thucLinh);
}


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Line 13: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
Line 14: error: expected declaration specifiers or '...' before 'NhanVien'
In function 'main':
Line 18: error: 'NhanVien' undeclared (first use in this function)
Line 18: error: (Each undeclared identifier is reported only once
Line 18: error: for each function it appears in.)
Line 18: error: 'NV' undeclared (first use in this function)
Line 23: error: 'for' loop initial declaration used outside C99 mode
Line 24: error: too many arguments to function 'xuatNhanVien'
t.c: At top level:
Line 30: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
Line 47: error: expected declaration specifiers or '...' before 'NhanVien'
In function 'xuatNhanVien':
Line 48: error: 'NV' undeclared (first use in this function)


Create a new paste based on this one


Comments: