将结构的指针成员传递给函数时发生预期的错误)

时间:2019-01-23 03:38:29

标签: c function pointers structure

我是C的初学者。在我的程序中,我具有结构和功能。我正在尝试传递结构中存在的指针作为函数中的参数。但是它在点运算符处显示错误“ Expected”。这很令人困惑,因为我函数的其他参数也来自结构,但是在这些函数中看不到此错误。

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

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 
}

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

2 个答案:

答案 0 :(得分:2)

在另一个函数中具有函数的是not possible in C ...

因此,您的代码应如下所示:

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);
}

答案 1 :(得分:1)

SELECT id, COUNT(*) AS count,
       CASE WHEN MAX(marketingid)=0 AND MIN(marketingid)=0
            THEN 'count(distinct sessionid)'
            ELSE 'count(distinct marketingid)' END AS methodology 
  FROM your_table
 GROUP BY id, marketingid, sessionid