“&&” and “and” operator in C

前端 未结 8 1858
名媛妹妹
名媛妹妹 2020-11-30 10:05

I am trying to calculate the Greatest Common Denominator of two integers.

C Code:

#include 

int gcd(int x, int y);

int main()
{
             


        
8条回答
  •  天命终不由人
    2020-11-30 10:16

    and is just an alternative token for &&.

    We can easily quote the standard here :

    2.6 Alternative tokens [lex.digraph]

    In all respects of the language, each alternative token behaves the same, respectively, as its primary token, except for its spelling. The set of alternative tokens is defined in Table 2.

    In table 2 :

       Alternative | Primary
            and    |    &&
    

    But I suggest you to use &&. People used to C/C++ may get confused by and...


    Since it is merged now, we are talking also about C, you can check this page ciso646 defining the alternatives tokens.

    This header defines 11 macro constants with alternative spellings for those C++ operators not supported by the ISO646 standard character set.

    From the C99 draft standard :

    7.9 Alternative spellings

    The header defines the following eleven macros (on the left) that expand to the corresponding tokens (on the right):

       and    &&
    

提交回复
热议问题