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!


Recommended Answers

All 2 Replies

This usually means object is just a pointer -- there's no storage space.

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.