?
Solved

Structure pointer

Posted on 2003-03-19
3
Medium Priority
?
161 Views
Last Modified: 2010-04-15
I have a strcutre tye:

struct Pkt
{
        char    Src_ID;
        int             Src_Pkt_ID;
        int             NAV;
        struct  Pkt_body payload[3];
};
where
struct Pkt_body
{
        char    Des_Node_ID;
        int             Des_Node_Pkt_ID;
        int             T_delay;
};


In my main program, I have created a

struct Pkt A, C, *B_ptr;

After I have define values for A, I did


B_ptr=&A;
C=*B_ptr;

Everything has copy from A to C apart from
Des_Node_ID and Des_Node_Pkt_ID

in the 3rd array of Pkt_body, it gace me funny symbol as "„¤ 4214921"

Any idea of any cause of this?
 Many thanks!

tabo

0
Comment
Question by:tabo_03
  • 2
3 Comments
 
LVL 4

Expert Comment

by:havman56
ID: 8166952
the way u initialise the A  may be aproblem

i have executed the program and debuged and seen it is working fine this is my code.




struct Pkt_body
{
       char    Des_Node_ID;
       int             Des_Node_Pkt_ID;
       int             T_delay;
};

struct Pkt
{
       char    Src_ID;
       int             Src_Pkt_ID;
       int             NAV;
       struct  Pkt_body payload[3];
};

struct Pkt A={ '2',1,2,
                     3,4,5,
                     6,7,8,
                     9,10,11
                   
               };



struct Pkt C, *B_ptr;
                   
main()          

{



B_ptr=&A;
C=*B_ptr;


}
0
 
LVL 4

Accepted Solution

by:
havman56 earned 150 total points
ID: 8166966
i have seen debug windows

+     B_ptr     0x0042ba30 struct Pkt  A
-     C     {...}
     Src_ID     0x32 '2'
     Src_Pkt_ID     0x00000001
     NAV     0x00000002
-     payload     0x0042d454
-     [0x0]     {...}
     Des_Node_ID     0x03 ''
     Des_Node_Pkt_ID     0x00000004
     T_delay     0x00000005
-     [0x1]     {...}
     Des_Node_ID     0x06 ''
     Des_Node_Pkt_ID     0x00000007
     T_delay     0x00000008
-     [0x2]     {...}
     Des_Node_ID     0x09 '     '
     Des_Node_Pkt_ID     0x0000000a
     T_delay     0x0000000b
0
 

Author Comment

by:tabo_03
ID: 8168419
Thanks very much, there was some problem with the array in the rest of the program and got a bit confused....

Thanks again!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question