From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 90652 invoked by alias); 4 Mar 2016 18:34:50 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 90640 invoked by uid 89); 4 Mar 2016 18:34:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.2 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=schwab@linux-m68k.org, schwablinuxm68korg, D*linux-m68k.org, 58ca X-HELO: mail-out.m-online.net Received: from mail-out.m-online.net (HELO mail-out.m-online.net) (212.18.0.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Fri, 04 Mar 2016 18:34:48 +0000 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 3qGyQr5t18z3hjWw; Fri, 4 Mar 2016 19:34:44 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 3qGyQr4rM8zvSf5; Fri, 4 Mar 2016 19:34:44 +0100 (CET) Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavisd-new, port 10024) with ESMTP id fxCzO27ARHU3; Fri, 4 Mar 2016 19:34:43 +0100 (CET) X-Auth-Info: T5RXglFUAufoebRnc7GeCcVFAfKuOVEBDBEUmV5uFmmI4HyuiJj+lY2DokldBDuF Received: from igel.home (ppp-88-217-4-200.dynamic.mnet-online.de [88.217.4.200]) by mail.mnet-online.de (Postfix) with ESMTPA; Fri, 4 Mar 2016 19:34:43 +0100 (CET) Received: by igel.home (Postfix, from userid 1000) id 3FD752C33D7; Fri, 4 Mar 2016 19:34:43 +0100 (CET) From: Andreas Schwab To: Neven Sajko Cc: Jan Kratochvil , gdb@sourceware.org Subject: Re: Printing a 2D array in a C program References: <20160304144231.GA7767@host1.jankratochvil.net> X-Yow: Two LITTLE black dots and one BIG black dot...nice 'n' FLUFFY!! Date: Fri, 04 Mar 2016 18:34:00 -0000 In-Reply-To: (Neven Sajko's message of "Fri, 4 Mar 2016 17:15:26 +0100") Message-ID: <87k2lim6rg.fsf@linux-m68k.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.92 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2016-03/txt/msg00011.txt.bz2 Neven Sajko writes: > In my question I asked about C (not C++), I even mentioned the > gcc -std=gnu90 option. > > My code is thus: > > enum { > sz = 17 > }; > > void p(int m[sz][sz], int n) { > int i; > for (i=1; i int j; > for (j=i-1; 0<=j; j--) { > m[i][j] = abs(3*m[i-1][j] +2*m[i][j+1]) % 9340506; > } > } > } > > void f(int n) { > int m[sz][sz]; > > g(m, n); > > p(m, n); > > r(m, n); > } > > > So, when I am in f, `info locals` prints it like {{a11, ..., > a1n}, ..., {an1, ..., ann}}. > But in p `print *m` just gets me {a11, ..., a1n}. This is correct, *m has the type int[sz]. If you want to print all elements pointed to by m you need to use `print *m@sz'. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."