【发布时间】:2021-12-04 15:46:10
【问题描述】:
{
int degree;
double *coeff;
};
struct poly create_poly()
{// Ask the user to enter the degree of the polynomial and (degree +1) coefficients
struct poly p;
printf("Power of the polynomial : ");
scanf("%d", &p.degree);
p.coeff = malloc((p.degree + 1) * sizeof *p.coeff);
for (int i = 0; i <= p.degree; i++)
{// Read a double as coeff
printf("Enter the coeff x^%d : ", i);
scanf("%lf", &p.coeff[i]);
}
return p;
}
int main{
struct poly p1 = create_poly();
struct poly p2 = create_poly();
struct poly p3 = create_poly();
}
假设我有一个看起来像struct poly 的结构。我有一个创建结构实例的函数,即create_poly。主函数是该函数用于创建实例的地方。假设我想删除实例 p2。我该如何继续呢?
谢谢你
【问题讨论】:
标签: c