Very messy type conversion

  • frankly
  • Beginner
  • Beginner
  • frankly
  • Posts: 52

Post 3+ Months Ago

Hi ppl it's me again :D

This time I got some really messy type definitions hehe
I defined
Code: [ Select ]
typedef struct {
    ELEMENT    e[sizeof(int)];
} FIELD2N;
  1. typedef struct {
  2.     ELEMENT    e[sizeof(int)];
  3. } FIELD2N;

and I have
Code: [ Select ]
typedef unsigned long ELEMENT;

and....
Code: [ Select ]
typedef struct
{
    FIELD2N        c;
    FIELD2N        d;
} SIGNATURE;
  1. typedef struct
  2. {
  3.     FIELD2N        c;
  4.     FIELD2N        d;
  5. } SIGNATURE;

let's say I have
Code: [ Select ]
SIGNATURE signature;

then how do I pass "signature.c" as a char array parameter and then later on recover from it back to the original type FIELD2N? Is it I can simply use (char *) signature.c?

Kinda messy to me........ 8O
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • frankly
  • Beginner
  • Beginner
  • frankly
  • Posts: 52

Post 3+ Months Ago

Actually I think I'm simply trying to convert a unsigned long array into char array. Coz I wanna use
Code: [ Select ]
ssize_t write(int filedes, const void *buff, size_t nbytes);

and yes I think the "buff" can be any pointer. So anyone knows how to write those "ELEMENT" into a file?
Thanz!!

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 100 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.