C 将结构的指针成员传递给函数时(应为错误)

C 将结构的指针成员传递给函数时(应为错误),c,function,pointers,structure,C,Function,Pointers,Structure,我是C语言的初学者。在我的程序中,我有一个结构和一个函数。我试图传递一个指针,它作为函数中的参数出现在结构中。但它在点运算符处显示错误“预期”)。这是令人困惑的,因为我的函数的其他参数也来自该结构,但这些参数中没有看到此错误 我尝试将函数的返回类型更改为所有类型,但仍然没有任何结果 struct signal { bool *input; int previousop; int n; }s; //my structure void noiseremove(bool *input, int n,

我是C语言的初学者。在我的程序中,我有一个结构和一个函数。我试图传递一个指针,它作为函数中的参数出现在结构中。但它在点运算符处显示错误“预期”)。这是令人困惑的,因为我的函数的其他参数也来自该结构,但这些参数中没有看到此错误

我尝试将函数的返回类型更改为所有类型,但仍然没有任何结果

struct signal
{
bool *input;
int previousop;
int n;
}s; //my structure
void noiseremove(bool *input, int n, int count1, int count0, bool 
previousop)//function i declared and defined before main function
{//my function here}
void main()
{
void noiseremove(bool *s.input , int s.n, int s.count1, int s.count0, bool 
s.previousop); //this is where i call the function and facing an error at 
*s.input 
}

我不确定我在这里哪里出错,或者语法是否错误。我希望函数能够接受参数,但事实并非如此。

在另一个函数中包含函数是

因此,您的代码应该是这样的:

struct signal
{
    bool *input, previousop;
    int n, count0, count1;
} s;

void noiseremove(bool *input, int n, int count1, int count0, bool previousop)
{
    /* Try using multi-line comments since single-line comments can comment out the end
       braces as well...*/
}

void main()
{
    /* Initialize the structure before accessing any of its variables, or it will lead
       to undefined behavior! */
    s = {0};
    /* Don't declare the identifiers again... It is 'syntax error' and 
       your calling convention doesn't in the least look like a calling 
       convention but more like a function declaration with invalid identifiers
       for the parameters... */
    noiseremove(s.input , s.n, s.count1, s.count0, s.previousop);
}

在另一个函数中包含函数是

因此,您的代码应该是这样的:

struct signal
{
    bool *input, previousop;
    int n, count0, count1;
} s;

void noiseremove(bool *input, int n, int count1, int count0, bool previousop)
{
    /* Try using multi-line comments since single-line comments can comment out the end
       braces as well...*/
}

void main()
{
    /* Initialize the structure before accessing any of its variables, or it will lead
       to undefined behavior! */
    s = {0};
    /* Don't declare the identifiers again... It is 'syntax error' and 
       your calling convention doesn't in the least look like a calling 
       convention but more like a function declaration with invalid identifiers
       for the parameters... */
    noiseremove(s.input , s.n, s.count1, s.count0, s.previousop);
}

“我不确定我在这里出了什么问题”-
void noiseremove(bool*s.input,int s.n,int s.count1,int s.count0,bool s.previousop)是错误的。这不是一个函数调用;那是一个构造不当的原型。如果语法错误,它将无法编译(这也不会)。如果逻辑是错误的(但语法是正确的,但事实并非如此),它要么无法正确运行,要么在最坏的情况下,似乎运行正确,但这仅仅是因为未定义的行为就是这样;未定义。转到您的书/教程,查看如何调用函数。调用函数时,它应该类似于-noiseremove(s.input,s.n,s.count1,s.count0,s.previousop);调用函数时不应定义参数类型等。“我不确定这里哪里出了问题”-
void noiseremove(bool*s.input,int s.n,int s.count1,int s.count0,bool s.previousop)是错误的。这不是一个函数调用;那是一个构造不当的原型。如果语法错误,它将无法编译(这也不会)。如果逻辑是错误的(但语法是正确的,但事实并非如此),它要么无法正确运行,要么在最坏的情况下,似乎运行正确,但这仅仅是因为未定义的行为就是这样;未定义。转到您的书/教程,查看如何调用函数。调用函数时,它应该类似于-noiseremove(s.input,s.n,s.count1,s.count0,s.previousop);调用函数时不应定义参数类型等。