# 当使用std :: cin输入结构时，它会出错

i have tried some little tweaks like using `std::` but didnt work at all

``````#include<iostream>
#include<math.h>
//#define str string
//using namespace std

int inputStarted=1;//being used in inputCo function

struct cords{
float x;
float y;
};

float distance(cords a,cords b){
float distanceX;
float distanceY;
distanceX= (a.x-b.x)*(a.x-b.x);
distanceY= (a.y-b.y)*(a.y-b.y);
return sqrt(distanceX+distanceY);
}
void area(cords A, cords B, cords C){
float ab =distance(A,B);
float ac =distance(A,C);
float bc =distance(B,C);
float S=(ab+ac+bc)/2;
float Area=sqrt(S*(S-ab)*(S-ac)*(S-bc));
std::cout<<Area;
}
void printCords(cords a){
std::cout<<std::endl<<std::endl<<"x - "<<a.x<<std::endl<<std::endl<<"y - "<<a.y<<std::endl<<std::endl;
}
void inputCo(cords a){
if(inputStarted==1){
std::cout<<"input your 1-st point's X position/coordinate  -  ";// = 1
std::cin>>a.x;
std::cout<<"input your 1-st point's Y position/coordinate  -  ";// = 4
std::cin>>a.y;
std::cout<<std::endl;
}
if(inputStarted==2){
std::cout<<"input your 2-nd point's X position/coordinate  -  ";// = 5
std::cin>>a.x;
std::cout<<"input your 2-nd point's Y position/coordinate  -  ";// = 8
std::cin>>a.y;
std::cout<<std::endl;
}
if(inputStarted==3){
std::cout<<"input your 3-rd point's X position/coordinate  -  ";// = 3
std::cin>>a.x;
std::cout<<"input your 3-rd point's Y position/coordinate  -  ";// = 6
std::cin>>a.y;
std::cout<<std::endl;
}
inputStarted++;
}
int main(){
cords A;
cords B;
cords C;
inputCo(A);
inputCo(B);
inputCo(C);
printCords(A);
printCords(B);
printCords(C);
area(A,B,C);
}```
``````

• 禁锢的誓言 回复
``````void inputCo(cords a){
``````

您正在按副本传递参数，因此仅修改了复制的值。要修改原始值，请通过引用传递：

``````void inputCo(cords& a){
``````

其他功能不会修改参数，因此您可以通过副本传递该参数。

• Oo傻吖頭 回复

您正在将coord的副本传递到已修改的输入函数中，并且当该函数退出时，该副本不再是您正在使用的副本。

您需要传入一个指针或对该坐标的引用，以便可以在不进行复制的情况下对其进行修改

将输入功能更改为：

``````void inputCo(cords &a)
``````