gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to print struct in GDB


From: vamsi krishna
Subject: Re: how to print struct in GDB
Date: Mon, 3 Sep 2007 17:24:27 -0400

> i wanted to show only the first field of the struct array which itself would
> be the
> char array of name of 50 elements. but ur comand is display only the name
> field

You need to write a simple script as follows.
<---------------------------------------------->
(gdb) set $i=50
(gdb) while ($i!=0)
> print ((struct node *) &SS[$i-1])->name
> set $i=$i-1
>end
<---------------------------------------------->

>
> On 9/3/07, vamsi krishna <address@hidden> wrote:
> > print ((struct node *) &SS[0])->name
> >
> > On 9/3/07, ddd sh < address@hidden> wrote:
> > > hi,
> > >
> > >  i hav array of following struct which contains 50 elements. I want to
> > >  print only first feild of the struct ie name field in GDB debuggure.
> > >
> > >
> > >  struct node {
> > >
> > >  char name[17] ;
> > >  int age;
> > >  char sex;
> > >  int location
> > >  } SS[50]
> > >
> > >
> > >  after running 50 loops if i m using (gdb) print SS
> > >  command it will show the all element and field of the array SS[50]
> > >  but how to get first ie name field of array SS[50]
> >
> >
> > --
> > Sincerely,
> > Vamsi Kundeti
> >
>
>


-- 
Sincerely,
Vamsi Kundeti




reply via email to

[Prev in Thread] Current Thread [Next in Thread]