C: Is this type of initialization correct?

int startingPoint[2]={i,j};

I got this after reading the online code. Is it correct? So, if the values ​​of i and j can be changed at run time before this statement, will this initialize the array with the correct values? Explain, please.

+3
source share
2 answers

This works on C99, but not on C89.

+8
source

int startPoint [2] = {i, j};
I got this after reading the online code. Is it correct?

Yes, this is the correct C code (will work on all modern C compilers). However, this will not work on the C89 compiler.

, j , ?

!

scanf("%d %d",i,j);
/* some code */

int abc[]={i,j};
+1

Source: https://habr.com/ru/post/1729355/


All Articles