![]() |
| | #1 |
| Comment your source code! Join Date: Apr 2002
Posts: 533
| viewing declared struct objects using gdb Code: #include <stdio.h>
struct blah
{
int id;
char* user;
};
int main()
{
struct blah mystrct;
mystrct.id = 1;
mystrct.user = "hi there\n";
fprintf(stdout,mystrct.user);
return 0;
}
mystrct.user or mystrc.id assuming I have a breakpoint at fprintf. when typing print mystrct or mystrct.user it says cannot view struct objects or something. Would I have to pick apart the stack? -LC
__________________ Asking the right question is sometimes more important than knowing the answer. Please read the FAQ C Reference Card (A MUST!) Pointers and Memory The Essentials CString lib |
| Lynux-Penguin is offline | |
| | #2 |
| Comment your source code! Join Date: Apr 2002
Posts: 533
| err hehehe- ^_^ Turns out that the part I was trying to debug wouldn't have helped anyway, I did this stupid thing earlier which caused a seg-fault: Code: fp = fopen("somefile.txt","rw");
fprintf(fp,"blah");
fclose(fp);
I can't believe I made that mistake either, but thanks for the help, I'll use that when I need to. But, I couldn't find out how to display members of a struct. Oh well- -LC
__________________ Asking the right question is sometimes more important than knowing the answer. Please read the FAQ C Reference Card (A MUST!) Pointers and Memory The Essentials CString lib Last edited by Lynux-Penguin; 07-20-2003 at 06:49 PM. |
| Lynux-Penguin is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Looking for constructive criticism | wd_kendrick | C Programming | 16 | 05-28-2008 09:42 AM |
| Global Variables | Taka | C Programming | 34 | 11-02-2007 03:25 AM |
| Looking for a way to store listbox data | Welder | C Programming | 20 | 11-01-2007 11:48 PM |
| Help please im stuck | ItsMeHere | C Programming | 7 | 06-15-2006 04:07 AM |
| Nested loop frustration | caroundw5h | C Programming | 14 | 03-15-2004 09:45 PM |