Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

quick question

Name: Anonymous 2009-02-12 19:20

Quick question: I have a trace file in binary, each trace is 12 bytes and I have the appropriate struct defined (using C obviously).

I'm using fgets() to read 12 bytes into a char[], and setting the struct's pointer to the char[]'s address, with the hopes that the data read will "fall into place." It isn't working, though, because I know that I don't have 0xFF registers.

Can someone give me an idea what I'm doing wrong? Thanks in advance. Here's my code (with fopen(), etc omitted):

struct trace_item {
uint8_t type;
uint8_t sReg_a;
uint8_t sReg_b;
uint8_t dReg;
uint32_t PC;
uint32_t Addr;
};

// snip
struct trace_item * cur;
char line[12];

cur = line;
while(fgets(line,12,f) != NULL)
{
printf("%x\n",cur->dReg);
}

Name: Anonymous 2009-02-13 6:08

struct trace_item cur;

while(fgets(&cur,12,f) != NULL)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List