Hello all!
I have used this forum many times in the past to solve a variety of programming related problems, but am truly stumped on a segfault within a binary search tree. I have isolated the segfault to a fscanf statement that look legitamate to me. The following code blocks are the function that contains the fscanf statement:

int fscan_unit(FILE *filep, object_t *object){

    int status;

    /************************** SEGFAULT **************************/
    status = fscanf(filep, "%d%d%d%s", &object->id,
                                       object->course );
    /************************** SEGFAULT **************************/

    if(status == 4){
        status = 1;
    else if(status != EOF){
        status = 0;

    return status;

and the structure template that is being writen to.

typedef struct object_s{
    int id,
    char course[7];

Let me know if you need to see any more of the code (I think these two bits are the important parts).
Thanks in advance for any help on this one!


4 Years
Discussion Span
Last Post by vikingsheepman

oops! yep that was it... I passed a pointer instead of a pointer to object. I should have seen that one :(
Thanks a ton man!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.