Frage: Aus einem array lesen?



  • Hi Leute!!

    ich habe schon wieder eine Frage!! 🙂

    Ich muss ein Element oder eine Instruction aus dem array lesen. und dann
    Ich mache es so;

    for ( i =0; i < entries; i++){
          /* read every instruction from the inputfile*/
           fread (&array[i], (blocksize/8),1, inputfile);
    	  /* c is a instruction of inputfile */ 
    	   c = array[i];
    	 /* Translate to an index */
        (1) symbol = conv->instr2symbol[c];
    

    }

    mache Ich es richtig ? Oder darf man so nicht machen?

    Mit Debuger kriege Ich so etwas in der Zeile (1) :
    "Unbehandelte Ausnahme bei 0x0041280b in AC.exe: 0xC0000005: Zugriffsverletzung -Leseposition 0x37694750.

    Was mache Ich falsch ???????

    Bitte hilft mir !!!!!!

    Im Voraus Vielen Dank !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    Viele Grüsse

    lena



  • Hast du gechecked, ob die Daten überhaupt richtig in array gelesen werden?

    Was ist instr2symbol in der Struktur conv denn genau?

    Sorry, aber meine Kristallkugel ist heute so trüb 😉



  • Hallo!!

    Danke für deinen Antwort.
    Ich habe überprüft: die daten werden aus array richtig gelesen.
    Der array instr2symbol[c] gehört zu structur conv.

    Ich brauche das array, um die Instructionen c in symbol umzuwandeln, damit Ich weiter mit symbol arbeiten kann.

    for(i =0; i< entries; i++){     /* Set up tables that */
    	conv->instr2symbol[i]=i+1;  /* translate between symbol */
          }
    
    symbol = conv->instr2symbol[c];
    

    Ich arbeite mit einem binären File. Ich habe mit einer Formel die Anzhal der Instruktione (8 Bit: Z.B. 00100100 oder 0x24 ) herausgefunden, und dann muss Ich jede Instruction einzeln behandeln.

    In Beispiel steht für textfile so:

    c = getc(inpufile);
    symbol = conv->instr2symbol[c];
    

    Deswegen weiss nicht, ob Ich richtig die einzelne Instuction aus dem binären File auslese.
    Das wäre toll, wenn Du mir helfen würdest !!!!

    Im Voraus Vielen Dank

    Lena


Anmelden zum Antworten