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

Pages: 1-

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-12 19:24

while(fgets(line,12,f) != NULL)

............................................________
....................................,.-‘”...................``~.,
.............................,.-”...................................“-.,
.........................,/...............................................”:,
.....................,?......................................................\,
.................../...........................................................,}
................./......................................................,:`^`..}
.............../...................................................,:”........./
..............?.....__.........................................:`.........../
............./__.(.....“~-,_..............................,:`........../
.........../(_....”~,_........“~,_....................,:`........_/
..........{.._$;_......”=,_.......“-,_.......,.-~-,},.~”;/....}
...........((.....*~_.......”=-._......“;,,./`..../”............../
...,,,___.\`~,......“~.,....................`.....}............../
............(....`=-,,.......`........................(......;_,,-”
............/.`~,......`-...............................\....../\
.............\`~.*-,.....................................|,./.....\,__
,,_..........}.>-._\...................................|..............`=~-,
.....`=~-,_\_......`\,.................................\
...................`=~-,,.\,...............................\
................................`:,,...........................`\..............__
.....................................`=-,...................,%`>--==``
........................................_\..........._,-%.......`\
...................................,<`.._|_,-&``................`\

Name: Anonymous 2009-02-12 19:25

Programming does not work this way.

Name: Anonymous 2009-02-12 19:28

It looks like you're not using LISP. That is likely the problem.

Name: Anonymous 2009-02-12 20:05

>>1
. . .

I'll post the answer in about ten hours if noone does.

Name: Anonymous 2009-02-12 20:07

>>3
This man is correct.

Name: Anonymous 2009-02-12 21:29

>>1
lol

Name: Anonymous 2009-02-12 21:30

void putStr(char* w){
    if(*w){
        putchar(*w);
        putStr(w+1,len-1);
    }
}

Name: Anonymous 2009-02-12 22:28

u need to read big endian

Name: Anonymous 2009-02-13 6:08

struct trace_item cur;

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

Name: Anonymous 2009-02-13 6:20

>>10
ding

Name: Anonymous 2009-02-13 8:17

>> 10
DON'T HELP... nevermind.

Name: Anonymous 2009-02-13 17:09


                     ##################
                ############################
              ################################
            ####################################
          ########################################
        ############################################
       ##############################################
      #############                      #############
     #########                                #########
     #######                                    #######
    ######                                        ######
    #####                                          #####
   #####                                            #####
   ####                                              ####
   ####                                              ####
   ####                                              ####
   ####                                              ####
   #####                                            #####
   #####                                            #####
    #####                                          #####
    ######                                        ######
     #######                                    #######
     #########                                #########
      #############                      #############
       ##############################################
        ############################################
          ########################################
            ####################################
              ################################
                ############################
                     ##################

Name: Anonymous 2009-08-16 22:45

Lain.

Name: Anonymous 2011-02-03 2:09

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