Click here to Skip to main content
15,867,453 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: 'x' bit OS Pin
«_Superman_»1-May-11 3:00
professional«_Superman_»1-May-11 3:00 
GeneralRe: 'x' bit OS Pin
Pranit Kothari1-May-11 3:14
Pranit Kothari1-May-11 3:14 
GeneralRe: 'x' bit OS Pin
Pranit Kothari10-May-11 22:40
Pranit Kothari10-May-11 22:40 
GeneralRe: 'x' bit OS Pin
«_Superman_»10-May-11 22:59
professional«_Superman_»10-May-11 22:59 
Questionproblem Pin
hmaz462930-Apr-11 23:49
hmaz462930-Apr-11 23:49 
AnswerRe: problem Pin
Rajesh R Subramanian1-May-11 0:01
professionalRajesh R Subramanian1-May-11 0:01 
AnswerRe: problem Pin
«_Superman_»1-May-11 2:16
professional«_Superman_»1-May-11 2:16 
Questionlinked list adding operation with two structure type Pin
quartaela30-Apr-11 3:42
quartaela30-Apr-11 3:42 
hi there i am working on a project that reads some data from a file and storing it into nodes. i actually made some operations like adding,deleting,search ect. in singly linked list with one structure type. now i am trying to use two structure types which are;

typedef struct node {

    int birth_date;
    int zipcode;
    int phone_num;
    char first_name[50];
    char last_name[50];
    char city[50];
    char address[50];
    char email_addr[50];

    struct node* fn_next;
    struct node* ln_next;
    struct node* birdat_next;

} NODE;

typedef struct {

    int count;
    NODE* head;
    NODE* tail;
    NODE* current;

}LIST;


and this is the block which i read and store the data and finally call add_Node function;
while ( !feof(myfile) ) {

        if( !(student = (NODE*) malloc(sizeof(NODE))) ) {

            printf("ERROR NOT ENOUGH MEMORY!!!\n");
            exit(100);
        }

        fscanf(myfile,"%s", &(student->first_name) );
        fscanf(myfile,"%s", &(student->last_name) );
        fscanf(myfile,"%s", &(student->email_addr) );
        fscanf(myfile,"%d", &(student->phone_num) );
        fscanf(myfile,"%s", &(student->address) );
        fscanf(myfile,"%s", &(student->city) );
        fscanf(myfile,"%d", &(student->zipcode) );

        add_Node(&list,student);

        printf("%s\n", student->first_name );

    }

}


and of course add_Node function;

void add_Node(LIST** list, NODE* student) {

        if( (*list)->head == NULL ) {

            student->fn_next = (*list)->head;
            (*list)->head = student;
            (*list)->tail = student;

            printf("Adding operation is succesfull\n");

            (*list)->count++;

            return;
        }

        else {

            (*list)->current = (*list)->head;

            while ( (*list)->current != NULL )

                (*list)->current = (*list)->current->fn_next;

            (*list)->current->fn_next = student;
            student->fn_next = NULL;

            (*list)->tail = (*list)->current;

            return;
        }
}


i am taking segmentation faults in add_Node and i don't know how to fix it.
AnswerRe: linked list adding operation with two structure type Pin
Luc Pattyn30-Apr-11 4:22
sitebuilderLuc Pattyn30-Apr-11 4:22 
GeneralRe: linked list adding operation with two structure type Pin
quartaela30-Apr-11 5:13
quartaela30-Apr-11 5:13 
AnswerRe: linked list adding operation with two structure type Pin
Luc Pattyn30-Apr-11 5:36
sitebuilderLuc Pattyn30-Apr-11 5:36 
AnswerRe: linked list adding operation with two structure type Pin
Andrew Phillips30-Apr-11 5:17
Andrew Phillips30-Apr-11 5:17 
GeneralRe: linked list adding operation with two structure type Pin
quartaela30-Apr-11 5:35
quartaela30-Apr-11 5:35 
GeneralRe: linked list adding operation with two structure type Pin
Andrew Phillips30-Apr-11 5:59
Andrew Phillips30-Apr-11 5:59 
AnswerRe: linked list adding operation with two structure type Pin
Luc Pattyn30-Apr-11 6:10
sitebuilderLuc Pattyn30-Apr-11 6:10 
GeneralRe: linked list adding operation with two structure type Pin
quartaela30-Apr-11 8:03
quartaela30-Apr-11 8:03 
GeneralRe: linked list adding operation with two structure type Pin
Luc Pattyn30-Apr-11 8:10
sitebuilderLuc Pattyn30-Apr-11 8:10 
GeneralRe: linked list adding operation with two structure type Pin
quartaela30-Apr-11 8:16
quartaela30-Apr-11 8:16 
GeneralRe: linked list adding operation with two structure type Pin
quartaela30-Apr-11 8:20
quartaela30-Apr-11 8:20 
GeneralRe: linked list adding operation with two structure type Pin
Luc Pattyn30-Apr-11 8:32
sitebuilderLuc Pattyn30-Apr-11 8:32 
QuestionProblem in Callback function in Client Application [modified] Pin
manoharbalu30-Apr-11 1:27
manoharbalu30-Apr-11 1:27 
AnswerRe: Problem in Callback function in Client Application Pin
Hans Dietrich30-Apr-11 4:27
mentorHans Dietrich30-Apr-11 4:27 
QuestionIs there any way to SendMessage to a Button control Pin
lamparded30-Apr-11 1:27
lamparded30-Apr-11 1:27 
AnswerRe: Is there any way to SendMessage to a Button control Pin
«_Superman_»30-Apr-11 2:12
professional«_Superman_»30-Apr-11 2:12 
GeneralRe: Is there any way to SendMessage to a Button control Pin
lamparded30-Apr-11 3:27
lamparded30-Apr-11 3:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.