From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28726 invoked by alias); 9 Jan 2008 22:29:23 -0000 Received: (qmail 28717 invoked by uid 22791); 9 Jan 2008 22:29:23 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 09 Jan 2008 22:28:54 +0000 Received: (qmail 10907 invoked from network); 9 Jan 2008 22:28:51 -0000 Received: from unknown (HELO localhost) (jimb@127.0.0.2) by mail.codesourcery.com with ESMTPA; 9 Jan 2008 22:28:51 -0000 To: Andrew STUBBS Cc: "'ranjith kumar'" , gdb@sourceware.org Subject: Re: printing a string References: <509320.35245.qm@web27407.mail.ukl.yahoo.com> <003701c8520c$2842c9d0$2e08a8c0@CAM.ARTIMI.COM> <4784A6E8.7090209@st.com> From: Jim Blandy Date: Wed, 09 Jan 2008 22:29:00 -0000 In-Reply-To: <4784A6E8.7090209@st.com> (Andrew STUBBS's message of "Wed, 09 Jan 2008 10:50:16 +0000") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes 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 X-SW-Source: 2008-01/txt/msg00059.txt.bz2 Andrew STUBBS writes: > Dave Korn wrote: >> On 08 January 2008 06:06, ranjith kumar wrote: >> >>> I know that a variable can be print in gdb by >>> "print var". >>> >>> But how to print a string??? >> >> "print" will display a string, if you're printing a variable of type "char >> *", or a std::string. >> >> Or you can use "x" (examine) with the "/s" modifier if you just have a >> memory address. > > Or, if your string is to long, or x/s is too ugly: > > printf "%s\n", mystring (Not 'set print elements'?)