does anyone know what this means?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nar0122
    New Member
    • Nov 2009
    • 11

    does anyone know what this means?

    Program received signal SIGSEGV, Segmentation fault.
    0x0000000000402 580 in writeBit (f=0x0, b=0) at binary1.cpp:26
    26 putc(b + '0', f->file);

    Information:

    writeBit function is as follows:

    /*************** *************** *************** **
    * writeBit *
    *************** *************** *************** **
    * Write bit b into open file f. b must be *
    * 0 or 1. *
    *************** *************** *************** **/

    void writeBit(BFILE* f, int b)
    {
    putc(b + '0', f->file);
    }

    ////////////////////////////////////////////////////////////////////////////////////////////////////////

    I only use writeBit 3 times.

    HERE

    //writeCode(f, str) writes string str to BFILE* f, one bit
    //at a time.
    void writeCode(BFILE * f, string str)
    {
    int y = str.length();
    for(int x = 0; x < y; x++)
    {
    writeBit(f, str[x]-'0');
    }

    }

    AND HERE
    void writeTree(BFILE * f, Node* t)
    {
    if(t->kind!=leaf)
    {
    writeBit(f, 0);
    writeTree(f, t->left);
    writeTree(f, t->right);
    }
    else
    {
    writeBit(f, 1);
    writeByte(f, t->ch);
    }


    }
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    SIGSEGV is a segmentation fault or memory access error. Often caused by either an invalid pointer operation, dereferencing a NULL or invalid pointer or an array out of bounds error, using a subscript outside the defined limits of the array.

    In this case I would guess that your BFILE* f pointer is invalid or NULL. Since that pointer is passed into the 2 functions you posted that call writeBit you have probably not posted the code with the error in it.

    Comment

    Working...