结构体实例— error LNK2001错误
来源:互联网 发布:java 获取版本号 编辑:程序博客网 时间:2024/05/16 18:20
/**************
用结构体数组做函数参数计算学生平均分
**************/
#include <stdio.h>
#define N 30
typedef struct date
{
int year;
int month;
int day;
}DATE;
typedef struct student
{
long studentID;
char studentName[10];
char studentSex;
DATE birthday;
int score[4];
}STUDENT;
void InputScore(STUDENT stu[],int n,int m)
{
int i,j;
for(i=0;i<n;i++)
{
printf("Input record %d\n",i+1);
scanf("%ld",&stu[i].studentID);
scanf("%s",&stu[i].studentName);
scanf(" %c",&stu[i].studentSex);
scanf("%d",&stu[i].birthday.year);
scanf("%d",&stu[i].birthday.month);
scanf("%d",&stu[i].birthday.day);
for(j=0;j<m;j++)
{
scanf("%d",&stu[i].score[j]);
}
}
}
void AverScore(STUDENT stu[],float aver[],int n,int m)
{
int i,j,sum[N];
for(i=0;i<n;i++)
{
sum[i] = 0;
for(j = 0;j<m;j++)
{
sum[i] = sum[i] +stu[i].score[j];
}
aver[i] = (float)sum[i]/m;
}
}
void PrintScore(STUDENT stu[],float aver[],int n,int m)
{
int i,j;
printf("Result:\n");
for(i=0;i<n;i++)
{
printf("%101d %8s %3c %6d %02d %02d",stu[i].studentID,stu[i].studentName,
stu[i].studentSex,stu[i].birthday.year,stu[i].birthday.month,stu[i].birthday.day);
for(j=0;j<m;j++)
{
printf("%4d",stu[i].score[j]);
}
printf("%601f\n",aver[i]);
}
}
int main()
{
float aver[N];
STUDENT stu[N];
int n;
printf("How many students?\n");
scanf("%d",&n);
InputScore(stu,n,4);
AverScore(stu,aver,n,4);
PrintScore(stu,aver,n,4);
return 0;
/*
报错:
Compiling...
31.cpp
Linking...
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/31.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
main写成mian了
*/
用结构体数组做函数参数计算学生平均分
**************/
#include <stdio.h>
#define N 30
typedef struct date
{
int year;
int month;
int day;
}DATE;
typedef struct student
{
long studentID;
char studentName[10];
char studentSex;
DATE birthday;
int score[4];
}STUDENT;
void InputScore(STUDENT stu[],int n,int m)
{
int i,j;
for(i=0;i<n;i++)
{
printf("Input record %d\n",i+1);
scanf("%ld",&stu[i].studentID);
scanf("%s",&stu[i].studentName);
scanf(" %c",&stu[i].studentSex);
scanf("%d",&stu[i].birthday.year);
scanf("%d",&stu[i].birthday.month);
scanf("%d",&stu[i].birthday.day);
for(j=0;j<m;j++)
{
scanf("%d",&stu[i].score[j]);
}
}
}
void AverScore(STUDENT stu[],float aver[],int n,int m)
{
int i,j,sum[N];
for(i=0;i<n;i++)
{
sum[i] = 0;
for(j = 0;j<m;j++)
{
sum[i] = sum[i] +stu[i].score[j];
}
aver[i] = (float)sum[i]/m;
}
}
void PrintScore(STUDENT stu[],float aver[],int n,int m)
{
int i,j;
printf("Result:\n");
for(i=0;i<n;i++)
{
printf("%101d %8s %3c %6d %02d %02d",stu[i].studentID,stu[i].studentName,
stu[i].studentSex,stu[i].birthday.year,stu[i].birthday.month,stu[i].birthday.day);
for(j=0;j<m;j++)
{
printf("%4d",stu[i].score[j]);
}
printf("%601f\n",aver[i]);
}
}
int main()
{
float aver[N];
STUDENT stu[N];
int n;
printf("How many students?\n");
scanf("%d",&n);
InputScore(stu,n,4);
AverScore(stu,aver,n,4);
PrintScore(stu,aver,n,4);
return 0;
}
/*
报错:
Compiling...
31.cpp
Linking...
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/31.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
main写成mian了
*/
阅读全文
1 0
- 结构体实例— error LNK2001错误
- error LNK2001错误
- error LNK2001错误(转)
- error LNK2001错误
- 连接错误error LNK2001
- <C++>error LNK2001错误
- ace error LNK2001错误
- 错误总结:error LNK2001
- error LNK2001: __imp___CrtDbgReportW 错误改正
- 【原创】error LNK2019: error LNK2001 错误
- error LNK2001: unresolved external symbol 错误分析
- 错误:error LNK2001: unresolved external symbol
- error lnk2001 的常见错误分析
- error LNK2001: unresolved external symbol 错误
- [转]vc error LNK2001 错误详述
- error LNK2001: unresolved external symbol 错误分析
- error LNK2001: __imp____glutCreateWindowWithExit (glut 错误)
- VC6.0 C++编程错误error LNK2001
- MyBatis的基本使用
- Apache配置多域名本地主机
- 对微信的简单介绍
- centos7 Linux环境的搭建
- opencv计算图像距离变换
- 结构体实例— error LNK2001错误
- Android-ADB-常用命令
- 直方图的反向投影
- Qt编译运行方式
- 直方图匹配
- RabbitMQ 官方NET教程(一)【介绍】
- 直方图变换-----累计
- win系统下nodejs安装及环境配置
- 进程学习3--getpid&getppid