๐’๐ก๐š๐ซ๐ž ๐ฒ๐จ๐ฎ๐ซ ๐ค๐ง๐จ๐ฐ๐ฅ๐ž๐๐ ๐ž. | Shalu Anand

Post

editor-img
Shalu Anand
Oct 12, 2022

๐’๐ก๐š๐ซ๐ž ๐ฒ๐จ๐ฎ๐ซ ๐ค๐ง๐จ๐ฐ๐ฅ๐ž๐๐ ๐ž.

๐ˆ๐ญโ€™๐ฌ ๐š ๐ฐ๐š๐ฒ ๐ญ๐จ

๐š๐œ๐ก๐ข๐ž๐ฏ๐ž ๐ข๐ฆ๐ฆ๐จ๐ซ๐ญ๐š๐ฅ๐ข๐ญ๐ฒ.

with this,

๐—Ÿ๐—ฒ๐˜'๐˜€ ๐—•๐—ฒ๐—ด๐—ถ๐—ป ๐ฐ๐ข๐ญ๐ก ๐ƒ๐š๐ฒ 6 :

๐šœ๐šŽ๐š›๐š’๐šŽ๐šœ ๐š˜๐š ๐šœ๐š‘๐šŠ๐š›๐š’๐š—๐š ๐š–๐šข ๐š”๐š—๐š˜๐š ๐š•๐šŽ๐š๐š๐šŽ ๐š˜๐š ๐š๐š‘๐šŽ ๐™ฒ ๐™ป๐šŠ๐š—๐š๐šž๐šŠ๐š๐šŽ.

char *arr[20];

int fn(char);

int (*fp)(void);

char *strings[10][20];

๐“๐ก๐ž ๐Ÿ๐จ๐ฅ๐ฅ๐จ๐ฐ๐ข๐ง๐  ๐ฌ๐ž๐ญ ๐จ๐Ÿ ๐จ๐ฉ๐ž๐ซ๐š๐ญ๐จ๐ซ๐ฌ ๐ฐ๐ข๐ญ๐ก ๐ข๐๐ž๐ง๐ญ๐ข๐œ๐š๐ฅ ๐ฉ๐ซ๐ž๐œ๐ž๐๐ž๐ง๐œ๐ž ๐š๐ง๐ ๐š๐ฌ๐ฌ๐จ๐œ๐ข๐š๐ญ๐ข๐ฏ๐ข๐ญ๐ฒ ๐š๐ซ๐ž ๐ซ๐ž๐ฎ๐ฌ๐ž๐ ๐ข๐ง ๐๐ž๐œ๐ฅ๐š๐ซ๐š๐ญ๐จ๐ซ๐ฌ, ๐ง๐š๐ฆ๐ž๐ฅ๐ฒ:

โšซ the unary * "dereference" operator which denotes a pointer;

โšซ the binary [] "array subscription" operator which denotes an array;

โšซ the (1+n)-ary () "function call" operator which denotes a function;

โšซ the () grouping parentheses which override the precedence and associativity of the rest of the listed operators.

๐Œ๐ฎ๐ฅ๐ญ๐ข๐ฉ๐ฅ๐ž ๐ƒ๐ž๐œ๐ฅ๐š๐ซ๐š๐ญ๐ข๐จ๐ง๐ฌ

The comma can be used as a separator (*not* acting like the comma operator) in order to delimit multiple declarations within a single statement.

๐“๐ก๐ž ๐Ÿ๐จ๐ฅ๐ฅ๐จ๐ฐ๐ข๐ง๐  ๐ฌ๐ญ๐š๐ญ๐ž๐ฆ๐ž๐ง๐ญ ๐œ๐จ๐ง๐ญ๐š๐ข๐ง๐ฌ ๐Ÿ๐ข๐ฏ๐ž ๐๐ž๐œ๐ฅ๐š๐ซ๐š๐ญ๐ข๐จ๐ง๐ฌ:

int fn(void), *ptr, (*fp)(int), arr[10][20], num;

The declared objects in the above example are:

โšซ fn: a function taking void and returning int;

โšซ ptr: a pointer to an int;

โšซ fp: a pointer to a function taking int and returning int;

โšซ arr: an array of size 10 of an array of size 20 of int;

โšซ num: int.

๐€๐ฅ๐ญ๐ž๐ซ๐ง๐š๐ญ๐ข๐ฏ๐ž ๐ˆ๐ง๐ญ๐ž๐ซ๐ฉ๐ซ๐ž๐ญ๐š๐ญ๐ข๐จ๐ง

Because declarations mirror use, a declaration can also be interpreted in terms of the operators that could be

applied over the object and the fifinal resulting type of that expression. The type that stands on the left-hand side is the fifinal result that is yielded after applying all operators.

char *arr[20];

int fn(char);

int (*fp)(void);

char *strings[10][20];