gpt4 book ai didi

c - 错误: request for member 'y' in something not a structure or union

转载 作者:行者123 更新时间:2023-11-30 17:29:56 26 4
gpt4 key购买 nike

我在编译时遇到问题。

这是我的主要内容:

int main(void) {

TP_Init();

Coordinate *dotyk;

while( 1 )
{
dotyk = Read_Ads7846();

int xx = *dotyk.x;
int yy = *dotyk.y;

TP_DrawPoint(xx,yy);
}
}

我的函数 Read_Ads 看起来:

Coordinate *Read_Ads7846(void) {

static Coordinate screen;
int m0,m1,m2,TP_X[1],TP_Y[1],temp[3];
uint8_t count=0;
int buffer[2][9]={{0},{0}};
do
{
TP_GetAdXY(TP_X,TP_Y);
buffer[0][count]=TP_X[0];
buffer[1][count]=TP_Y[0];
count++;
}
while(!TP_INT_IN&& count<9);
if(count==9)
{
temp[0]=(buffer[0][0]+buffer[0][1]+buffer[0][2])/3;
temp[1]=(buffer[0][3]+buffer[0][4]+buffer[0][5])/3;
temp[2]=(buffer[0][6]+buffer[0][7]+buffer[0][8])/3;

m0=temp[0]-temp[1];
m1=temp[1]-temp[2];
m2=temp[2]-temp[0];

m0=m0>0?m0:(-m0);
m1=m1>0?m1:(-m1);
m2=m2>0?m2:(-m2);
if( m0>THRESHOLD && m1>THRESHOLD && m2>THRESHOLD )
return 0;
if(m0<m1)
{
if(m2<m0)
screen.x=(temp[0]+temp[2])/2;
else
screen.x=(temp[0]+temp[1])/2;
}
else if(m2<m1)
screen.x=(temp[0]+temp[2])/2;
else
screen.x=(temp[1]+temp[2])/2;

temp[0]=(buffer[1][0]+buffer[1][1]+buffer[1][2])/3;
temp[1]=(buffer[1][3]+buffer[1][4]+buffer[1][5])/3;
temp[2]=(buffer[1][6]+buffer[1][7]+buffer[1][8])/3;
m0=temp[0]-temp[1];
m1=temp[1]-temp[2];
m2=temp[2]-temp[0];
m0=m0>0?m0:(-m0);
m1=m1>0?m1:(-m1);
m2=m2>0?m2:(-m2);
if(m0>THRESHOLD&&m1>THRESHOLD&&m2>THRESHOLD)
return 0;

if(m0<m1)
{
if(m2<m0)
screen.y=(temp[0]+temp[2])/2;
else
screen.y=(temp[0]+temp[1])/2;
}
else if(m2<m1)
screen.y=(temp[0]+temp[2])/2;
else
screen.y=(temp[1]+temp[2])/2;

return &screen;
}
return 0;
}

我收到错误:

request for member 'y' in something not a structure or union

我认为我需要使用 -> 运算符,但它也会导致错误。

你能解释一下哪里出了问题吗?

最佳答案

由于结构指针的原因,您需要 -> 而不是 .,并删除其前面的 *

应该是

int xx = dotyk->x;
int yy = dotyk->y;

关于c - 错误: request for member 'y' in something not a structure or union,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25443585/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com