I tried the following code in gcc:
#include<stdio.h> int main() { int a=3,2,1;//////////////////////ERROR!////////////////////////// printf("%d", a); return 0; }
I expected it to compile successfully as:
Then the value of the integer variable a should be 1 right? Or is it 3?
And why am I getting this error when trying to run this program?
error: expected identifier or '(' before a numeric constant
If you separate the initialization from the declaration, you can get what you expected:
int a; a = 3, 2, 1; // a == 3, see note bellow
or
int a; a = (3, 2, 1); // a == 1, the rightmost operand of 3, 2, 1
( , , 2 1)
2
1
. .
,
a = 3, 2, 1
3 a = 3, 2 1, ,
a = 3
a = 3, 2
2 ( ) (, , - , a = 3 3), , a = 3 , .. . 3 a. ( AnT .)
3
a
.
, :
int a=(3,2,1);
Source: https://habr.com/ru/post/1659201/More articles:startFirstResponder sometimes fails to open keyboard on ios 10 - iosVisual Studio Code Deletes Desired Line Breaks and Indents - indentationIn PyCharm, how do I delete the output of my Jupiter laptop when working with the IDE? - pycharmSpring Загрузка - как включить конечную точку REST из зависимости? - javaWeb API 2 Windows Authentication Continues to Request Login - authenticationEcto - nested embed update - elixirPiecewise affine transform + strain output looks weird - pythonhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1659204/typescript-21-coupled-with-the-angular-2-compiler-silently-fails-to-compile-project-files-no-output&usg=ALkJrhgFROZZcYE1dwMDrm0ZZMT7p8RyJQInheritance (or alternative) in parameterized jUnit tests - javaHow to understand the key value change in insertion sort? - cAll Articles