c++问题 关于结构error: expected primary-expression before '{' token

帮帮忙吧,初学者,可这个程序总也编译不了,自学真麻烦呀#include<cstdlib>#include<iostream>usingnamespacestd;intma... 帮帮忙吧,初学者,可这个程序总也编译不了,自学真麻烦呀
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
int number(0);
double number1(0);
double number2(0);
struct Convert
{
char convert_name[100];
double convert_rate;
};
Convert convert[3];
convert[0]={"yuan to dollar",0.125};
convert[1]={"dollar to pound",2};
convert[2]={"yuan to pound",0.0625};
cout<<"choose a way to convert money"<<endl<<"1.yuan to dollar"<<endl<<"2.dollar to pound"<<endl<<"3.yuan to pound";
cin>>number;
cout<<"please enter the type that you want to convert";
cin>>number1;
if(number<3&&number>=0)
number2=number1*convert[number-1].couvert_rate;
else
cout<<"sorry ,you entered a wrong number";
cout<<number1<<convert[number-1].convert_name<<" is "<<number2;

system("PAUSE");
return EXIT_SUCCESS;
}
下面是错误信息
Compiler: Default compiler
Building Makefile: "C:\Users\shanliho\Documents\Makefile.win"
Executing make...
make.exe -f "C:\Users\shanliho\Documents\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"

main.cpp: In function `int main(int, char**)':

main.cpp:17: error: expected primary-expression before '{' token

main.cpp:17: error: expected `;' before '{' token

main.cpp:18: error: expected primary-expression before '{' token

main.cpp:18: error: expected `;' before '{' token

main.cpp:19: error: expected primary-expression before '{' token

main.cpp:19: error: expected `;' before '{' token

main.cpp:25: error: 'struct main(int, char**)::Convert' has no member named 'couvert_rate'

make.exe: *** [main.o] Error 1

Execution terminated
展开
 我来答
你不爱吃烤肉
推荐于2019-08-02 · TA获得超过2万个赞
知道答主
回答量:234
采纳率:100%
帮助的人:7.7万
展开全部

如下:

#include <cstdlib>

#include <iostream>

using namespace std;

int main(int argc, char *argv[])

{

int number(0);

double number1(0);

double number2(0);

struct Convert

{

char convert_name[100];

double convert_rate;

};

Convert convert[3] = {{{"yuan to dollar"},0.125},{"dollar to pound",2},{"yuan to

pound",0.0625}};

cout<<"choose a way to convert money"<<endl<<"1.yuan to dollar"<<endl<<"2.dollar to

pound"<<endl<<"3.yuan to pound";

cin>>number;

cout<<"please enter the type that you want to convert";

cin>>number1;

if(number<3&&number>=0)

number2=number1*convert[number-1].convert_rate;

else

cout<<"sorry ,you entered a wrong number";

cout<<number1<<convert[number-1].convert_name<<" is "<<number2;

system("PAUSE");

return EXIT_SUCCESS;

}

扩展资料:

C++常用函数:

int abs(int x):求整数x的绝对值 

double acos(double x):计算arcos(x)的值 

double asin(double x):计算arsin(x)的值 

double atan(double x):计算arctan(x)的值 

double cos(double x):计算cos(x)的值 

double cosh(double x):计算x的双曲余弦cosh(x)的值 

double exp(double x):求的值 

double fabs(double x):求实数x的绝对值 

double fmod(double x):求x/y的余数 

long labs(long x):求长整型数的绝对值 

double log(double x):计算In(x)的值

double log10(double x):计算的值 

double modf(double x, double *y):取x的整数部分送到y所指向的单元格中 

double pow(double x, double y):求x的y次幂的值 

double sin(double x):计算sin(x)的值 

double tan(double x):计算tan(x)的值 

void abort(void):终止程序执行   

void exit(int):终止程序执行   

double atof(const char *s):将s所指向的字符串转换成实数 

int atoi(const char *s):将s所指向的字符串转换成整数 

long atol(const char *s):将s所指的字符串转换成长整数 

int rand(void):产生一个随机整数 

dulading
推荐于2018-02-26 · TA获得超过268个赞
知道小有建树答主
回答量:65
采纳率:0%
帮助的人:99.7万
展开全部
改好了,自己看吧。主要是字符数组初始化的问题,记住只有在定义字符数组的时候才可以用字符串给字符数组赋值。还有一个拼写错误,我也改过来了
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
int number(0);
double number1(0);
double number2(0);
struct Convert
{
char convert_name[100];
double convert_rate;
};
Convert convert[3] = {{{"yuan to dollar"},0.125},{"dollar to pound",2},{"yuan to pound",0.0625}};
cout<<"choose a way to convert money"<<endl<<"1.yuan to dollar"<<endl<<"2.dollar to pound"<<endl<<"3.yuan to pound";
cin>>number;
cout<<"please enter the type that you want to convert";
cin>>number1;
if(number<3&&number>=0)
number2=number1*convert[number-1].convert_rate;
else
cout<<"sorry ,you entered a wrong number";
cout<<number1<<convert[number-1].convert_name<<" is "<<number2;

system("PAUSE");
return EXIT_SUCCESS;
}
本回答被提问者和网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
EVA_RED
2019-02-22
知道答主
回答量:2
采纳率:0%
帮助的人:1570
展开全部
是因为在函数调用时 括号里的参数前面还加了变量类型 去掉这个变量类型就行了
(至少我的错误是这样的。。。其他情况就不清楚了)
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
奥妙腿J
2010-05-16
知道答主
回答量:26
采纳率:0%
帮助的人:0
展开全部
#include <studio.h>
void main()
{
int a=5,b=3;
scanf("d%,d%",&a,&b);
x=a*b;
printf("d%,d%,d%",a,b,x)
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式