函数传递结构地址的问题

#include
#include

using namespace std;

struct box
{
char maker[40];
float height;
float width;
float length;
float volume;
};

void pass_value(box);
void pass_adress(box*);

int main()
{
box* ps = new box;
ps->height = (*ps).width = ps->length = 10;
char word[] = "the world";
strcpy_s(ps->maker, word);
pass_value(*ps);
pass_adress(ps);
delete ps;
return 0;
}

void pass_value(box box_s)
{
cout << "maker: " << box_s.maker << endl;
cout << "height: " << box_s.height << endl;
cout << "width: " << box_s.width << endl;
cout << "length: " << box_s.length << endl<<endl;
}

void pass_address(box* pt)
{
cout << "volume= " << (pt->height)*(pt->width)*(pt->length) << endl;
}

图片说明

错误在哪里?求解答

3个回答

address少了个d

aaronmorgan
AaronJ1 回复world_pioneer: 初学者都会犯这种错的,而且自己还很难发现。
大约 4 年之前 回复
world_pioneer
world_pioneer 犯这种错误我还恬不知耻地发了上来。。。。。无地自容。。。。谢谢!!
大约 4 年之前 回复

上面的图不清晰,重发源代码
图片说明

函数原型和调用那里都没拼对

立即提问