?
Solved

Structure pointer

Posted on 2003-03-19
3
Medium Priority
?
160 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
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 opening and writing to files in the C programming language.
Suggested Courses

762 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