C运营商的问题

时间:2018-01-31 11:15:37

标签: c operators

我有这段代码:

long long int a = 3, *b = &a;
int c = !(a+=1, a>>=2, a--, !a);
printf ("%11d %d\n", a, c);

当我跑它时,它给了我0 0,但我不明白为什么。不应该是0 1?

2 个答案:

答案 0 :(得分:4)

展开代码并删除多余的内容:

cmake

答案 1 :(得分:3)

此代码使用逗号运算符,它按顺序计算操作,然后计算到最后一个。

{

    private void btnExport_Click(object sender, EventArgs e)
    {
        ExportToExcel(dataGridView1,"ExportedUserDetail");

    }
    public void ExportToExcel(DataGridView gridviewID, string excelFilename)
    {


        DateTime from = dateTimePicker1.Value;
        string date1 = from.ToString("MM/dd/yyyy");
        string fromdate = date1 + " " + "12:00:00" + " " + "AM";

        DateTime to = dateTimePicker2.Value;
        string date2 = to.ToString("MM/dd/yyyy");
        string todate = date2 + " " + "11:00:00" + " " + "PM";

        if (dateTimePicker1.Value != dateTimePicker2.Value)
        {
            string ConnString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Data\Test.accdb";
            DataTable Data = new DataTable();
            using (OleDbConnection conn = new OleDbConnection(ConnString))
            {
                conn.Open();//break

                OleDbCommand cmd = new OleDbCommand("select tb3.SeqNo as 'Session Sequence Number',tb3.SessionDate as 'Session Date',tb3.CustomerName as 'Customer Name',tb3.RepID as 'Rep ID',tb3.RepName as 'Rep Name',CaseRef as 'Ticket No',PracticeName as 'Practice Name',PostCode as 'Post Code',PhoneManner as 'Phone Manner',Satisfaction,iif (Satisfaction='EXCELLENT',5, iif (Satisfaction='VERY GOOD' ,4, iif (Satisfaction='GOOD' ,3, iif (Satisfaction='NEUTRAL' ,2, iif (Satisfaction='POOR' ,1))))) as Ratings,Ratings/5*100 as 'Percentage' , Consultant,CustomerComments as 'Customer Comments',Recommendation from tb1,tb3 where tb3.SeqNo=tb1.SeqNo and tb3.SessionDate between #" + fromdate + "# and #" + todate + "#", conn);
                OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
                adapter.Fill(Data);
                conn.Close();
                dataGridView1.DataSource = Data;

                Microsoft.Office.Interop.Excel.Application objexcelapp = new Microsoft.Office.Interop.Excel.Application();
                objexcelapp.Application.Workbooks.Add(Type.Missing);
                objexcelapp.Columns.ColumnWidth = 25;
                for (int i = 1; i < gridviewID.Columns.Count + 1; i++)
                {
                    objexcelapp.Cells[1, i] = gridviewID.Columns[i - 1].HeaderText;
                }
                /*For storing Each row and column value to excel sheet*/
                for (int i = 0; i < gridviewID.Rows.Count; i++)
                {
                    for (int j = 0; j < gridviewID.Columns.Count; j++)
                    {
                        if (gridviewID.Rows[i].Cells[j].Value != null)
                        {
                            objexcelapp.Cells[i + 2, j + 1] = gridviewID.Rows[i].Cells[j].Value.ToString();
                        }
                    }
                }
                MessageBox.Show("Your excel file exported successfully at d:\\" + excelFilename + ".xlsx");
                objexcelapp.ActiveWorkbook.SaveCopyAs("d:\\" + excelFilename + ".xlsx");
                objexcelapp.ActiveWorkbook.Saved = true;
            }
        }
        else

        {
            MessageBox.Show("Please select valid date...!!!");
        }
    }

}
}

对于那些有疑问的人来说 -

  

逗号运算符引入了一个序列点,因此在   代码f(),g()定义了评估的顺序:首先调用f(),   然后调用g()。