![]() |
| | #1 |
| Registered User Join Date: Jun 2009
Posts: 31
| I don't understand this code line: Code: struct iphdr *iph=(struct iphdr *)data; What I can see is that we are creating a pointer (iph) to a iphdr struct, but the right side is not very clear. Can anyone explain the meaning, please? Thanks in advance Dedalus |
| Dedalus is offline | |
| | #2 |
| Deathray Engineer Join Date: Mar 2007
Posts: 3,211
| If this example is too difficult to understand, you should get a good C book and learn the basics. The code is casting data to a struct iphdr * and then assigning it to the newly created variable iph. BTW, if you mean that data is an unsigned char, then this cast is rather horrible to do and makes little sense to me. In fact, this could be the cause of some ugly problems. Oh, and welcome to cboard.
__________________ Last edited by MacGyver; 06-10-2009 at 04:37 AM. Reason: Messed up spelling of type name. |
| MacGyver is offline | |
| | #3 |
| Registered User Join Date: Jun 2009
Posts: 31
| Thanks MacGyver |
| Dedalus is offline | |
![]() |
| Tags |
| pointer, struct |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Imposing Line Numbers automatically in the C code | cavestine | C Programming | 14 | 10-15-2007 12:41 AM |
| help again with scrolling without wrapping | Dukefrukem | C Programming | 8 | 09-21-2007 12:48 PM |
| How to do encryption in C | sankarv | C Programming | 31 | 09-21-2006 05:37 AM |
| Quick question about SIGSEGV | Cikotic | C Programming | 30 | 07-01-2004 07:48 PM |
| Request for comments | Prelude | A Brief History of Cprogramming.com | 15 | 01-02-2004 10:33 AM |