我写了一个c语言程序,但是运行总是出现下面的错误,我用的是VS 2010编辑器
#include<stdio.h>#include<stdlib.h>structINVEST{intnumber[8];doubleamount_invested[8]...
#include<stdio.h>
#include<stdlib.h>
struct INVEST
{
int number[8];
double amount_invested[8];
double profit[8];
double toplimit[8];
};
struct INVEST invest[8]={{1,6700,1139,41000},
{2,6600,1056,33000},
{3,4850,727.5,34000},
{4,5500,1265,29000},
{5,5800,1160,35000},
{6,4200,714,26000},
{7,4600,1840,27000},
{8,4500,1575,25000}};
int main(void)
{
struct TNVEST *pt;
printf(" 表一:投资项目所需资金及预计一年后所得利润\n");
printf("单位(万元)\n");
printf("项目编号\t\t每份投资额\t\t预计利润\t\t投资上限\t\t\n");
pt = invest;
printf("%d",pt->invest[1].number[1]);
while(getchar()!='/n'); //读走无关字符
printf("\n");
system("pause");
return 0;
}
warning C4244: “初始化”: 从“double”转换到“int”,可能丢失数据
warning C4133: “=”: 从“INVEST *”到“TNVEST *”的类型不兼容
error C2037: “invest”的左侧部分指定未定义的结构/联合“TNVEST”
跪求哪位大侠帮忙看看! 展开
#include<stdlib.h>
struct INVEST
{
int number[8];
double amount_invested[8];
double profit[8];
double toplimit[8];
};
struct INVEST invest[8]={{1,6700,1139,41000},
{2,6600,1056,33000},
{3,4850,727.5,34000},
{4,5500,1265,29000},
{5,5800,1160,35000},
{6,4200,714,26000},
{7,4600,1840,27000},
{8,4500,1575,25000}};
int main(void)
{
struct TNVEST *pt;
printf(" 表一:投资项目所需资金及预计一年后所得利润\n");
printf("单位(万元)\n");
printf("项目编号\t\t每份投资额\t\t预计利润\t\t投资上限\t\t\n");
pt = invest;
printf("%d",pt->invest[1].number[1]);
while(getchar()!='/n'); //读走无关字符
printf("\n");
system("pause");
return 0;
}
warning C4244: “初始化”: 从“double”转换到“int”,可能丢失数据
warning C4133: “=”: 从“INVEST *”到“TNVEST *”的类型不兼容
error C2037: “invest”的左侧部分指定未定义的结构/联合“TNVEST”
跪求哪位大侠帮忙看看! 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询