2 votes 2 votes main() { char a[2][3][3] = {'g','a','t','e','s','q','u','I','z'}; printf("%s",**a); the answer is gatequiz, to refer to a 3dimensional array the printf statement should be ***a right? A_i_$_h asked Jun 14, 2017 A_i_$_h 1.7k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes answer is correct . It will printf 'gatesquiz', because **a is giving the starting address of the first character and therefore 'printf ' will take the starting address and will print 'gatesquiz' but it you use ***a , it will give the value stored at first address i'e 'g' and hece will print( ***a ) will print 'g' on the console. You can also verify it here http://code.geeksforgeeks.org/XyBn7I bittu answered Jun 14, 2017 edited Jun 14, 2017 by bittu bittu comment Share Follow See all 6 Comments See all 6 6 Comments reply Show 3 previous comments Hemant Parihar commented Jun 15, 2017 reply Follow Share printf("%s", a); output = gatequiz warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[3][3]' printf("%s", *a); output = gatequiz warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[3]' printf("%s", **a); output = gatequiz There is no warning because %s expects argument of type 'char *' and **a also has type 'char *'. printf("%s", ***a); output = segmented fault. It is because %s expects 'char *' but ***a is referring to an int value. 2 votes 2 votes A_i_$_h commented Aug 19, 2017 reply Follow Share Sir can u show me how the 3 dimensional array values are stored i dont properly understand its storage may be that will help me solve such questions easier 0 votes 0 votes A_i_$_h commented Aug 19, 2017 reply Follow Share how ***a refers to an int value? 0 votes 0 votes Please log in or register to add a comment.