Click here to Skip to main content
15,912,837 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how to make folder to file extension Pin
Hans Dietrich2-May-11 6:02
mentorHans Dietrich2-May-11 6:02 
Questionimplementing multi linked list correctly_? Pin
quartaela1-May-11 23:52
quartaela1-May-11 23:52 
AnswerRe: implementing multi linked list correctly_? Pin
Stefan_Lang2-May-11 0:22
Stefan_Lang2-May-11 0:22 
GeneralRe: implementing multi linked list correctly_? Pin
quartaela2-May-11 0:28
quartaela2-May-11 0:28 
GeneralRe: implementing multi linked list correctly_? Pin
Stefan_Lang2-May-11 0:44
Stefan_Lang2-May-11 0:44 
GeneralRe: implementing multi linked list correctly_? Pin
quartaela2-May-11 0:56
quartaela2-May-11 0:56 
GeneralRe: implementing multi linked list correctly_? Pin
Stefan_Lang2-May-11 2:44
Stefan_Lang2-May-11 2:44 
GeneralRe: implementing multi linked list correctly_? Pin
quartaela2-May-11 4:06
quartaela2-May-11 4:06 
well i create the node outside of the add functions and pass the node to these functions. in these add functions i update the links. but the main thing is which confuses me i use two add functions.(which updating the pointer of first name and second one is for last name). so if i wanna use only one list with having two different pointers(firstname pointer and lastname pointer) must i use only one add function_? or two functions. because adding one node for two different sortings in just one function will be very difficult_?. and sorry for inconvenience situtaion of my problem : ): here is the code again of my creating and calling add functions;

while ( !feof(myfile) ) {

        NODE* pnew_stu;

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

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

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

        add_fn_Node(list,pnew_stu);
        add_ln_Node(list,pnew_stu);

}


and these are the adding functions

void add_fn_Node(LIST* list, NODE* pnew_stu) {

    NODE* temp = list->fn_head;

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

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

    if( list->fn_head == NULL ) {

            pnew_stu->fn_next = list->fn_head;
            pnew_stu->fn_pre = list->fn_head;


            list->fn_head = pnew_stu;

            list->fn_count = 1;

            return;

        }

        else {

            temp = list->fn_head;

            if ( (strcmp( pnew_stu->first_name, temp->first_name )) <= 0 ) { // Basa Ekleme Kosulu

                pnew_stu->fn_next = temp;
                pnew_stu->fn_pre = temp->fn_pre;
                temp->fn_pre = pnew_stu;

                list->fn_head = pnew_stu;

                list->fn_count++;

                return;

            }

            else {


                 while ( temp->fn_next != NULL ) { // Ortaya Ekleme Kosulu

                        if ( (strcmp( pnew_stu->first_name, temp->first_name ) <= 0 ) && (strcmp( pnew_stu->first_name, temp->fn_pre->first_name) > 0)) {

                        pnew_stu->fn_next = temp;
                        pnew_stu->fn_pre = temp->fn_pre;
                        temp->fn_pre->fn_next = pnew_stu;
                        temp->fn_pre = pnew_stu;

                        list->fn_count++;

                        return;
                    }

                        temp = temp->fn_next;

                    }

                if ( temp->fn_next == NULL ) { // Sona Ekleme Kosulu

                    temp->fn_next = pnew_stu;
                    pnew_stu->fn_pre = temp;
                    pnew_stu->fn_next = NULL;

                    list->fn_tail = pnew_stu;

                    list->fn_count++;

                    return;

                }
            }

        }
}

void add_ln_Node(LIST* list, NODE* pnew_stu) {

    NODE* temp = list->ln_head;

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

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

    if( list->ln_head == NULL ) {

            pnew_stu->ln_next = list->ln_head;
            pnew_stu->ln_pre = list->ln_head;


            list->ln_head = pnew_stu;

            list->ln_count = 1;

            return;

        }

        else {

            temp = list->ln_head;

            if ( (strcmp( pnew_stu->last_name, temp->last_name )) <= 0 ) { // Basa Ekleme Kosulu

                pnew_stu->ln_next = temp;
                pnew_stu->ln_pre = temp->ln_pre;
                temp->ln_pre = pnew_stu;

                list->ln_head = pnew_stu;

                list->ln_count++;

                return;

            }

            else {


                 while ( temp->ln_next != NULL ) { // Ortaya Ekleme Kosulu

                        if ( (strcmp( pnew_stu->last_name, temp->last_name ) <= 0 ) && (strcmp( pnew_stu->last_name, temp->ln_pre->last_name) > 0)) {

                        pnew_stu->ln_next = temp;
                        pnew_stu->ln_pre = temp->ln_pre;
                        temp->ln_pre->ln_next = pnew_stu;
                        temp->ln_pre = pnew_stu;

                        list->ln_count++;

                        return;
                    }

                        temp = temp->ln_next;

                    }

                if ( temp->ln_next == NULL ) { // Sona Ekleme Kosulu

                    temp->ln_next = pnew_stu;
                    pnew_stu->ln_pre = temp;
                    pnew_stu->ln_next = NULL;

                    list->ln_tail = pnew_stu;

                    list->ln_count++;

                    return;

                }
            }

        }
}


so am i not creating only one node and sending to these add functions_?. or am i creating two nodes again in functions and update them in the list_?
GeneralRe: implementing multi linked list correctly_? Pin
Stefan_Lang2-May-11 4:44
Stefan_Lang2-May-11 4:44 
GeneralRe: implementing multi linked list correctly_? Pin
quartaela2-May-11 4:59
quartaela2-May-11 4:59 
GeneralRe: implementing multi linked list correctly_? Pin
Stefan_Lang2-May-11 6:20
Stefan_Lang2-May-11 6:20 
GeneralRe: implementing multi linked list correctly_? Pin
quartaela2-May-11 7:38
quartaela2-May-11 7:38 
AnswerRe: implementing multi linked list correctly_? Pin
David Crow2-May-11 9:13
David Crow2-May-11 9:13 
GeneralRe: implementing multi linked list correctly_? Pin
quartaela2-May-11 9:37
quartaela2-May-11 9:37 
QuestionHow does Google Chrome Installer gets installed with UAC Prompt Pin
Raj Aryan 10011-May-11 22:29
Raj Aryan 10011-May-11 22:29 
AnswerRe: How does Google Chrome Installer gets installed with UAC Prompt Pin
Hans Dietrich1-May-11 22:53
mentorHans Dietrich1-May-11 22:53 
GeneralRe: How does Google Chrome Installer gets installed with UAC Prompt Pin
Raj Aryan 10011-May-11 23:00
Raj Aryan 10011-May-11 23:00 
AnswerRe: How does Google Chrome Installer gets installed with UAC Prompt Pin
Hans Dietrich1-May-11 23:06
mentorHans Dietrich1-May-11 23:06 
GeneralRe: How does Google Chrome Installer gets installed with UAC Prompt Pin
Raj Aryan 10011-May-11 23:13
Raj Aryan 10011-May-11 23:13 
AnswerRe: How does Google Chrome Installer gets installed with UAC Prompt Pin
Hans Dietrich2-May-11 5:36
mentorHans Dietrich2-May-11 5:36 
GeneralRe: How does Google Chrome Installer gets installed with UAC Prompt Pin
Raj Aryan 10012-May-11 5:49
Raj Aryan 10012-May-11 5:49 
AnswerRe: How does Google Chrome Installer gets installed with UAC Prompt Pin
Hans Dietrich2-May-11 6:04
mentorHans Dietrich2-May-11 6:04 
GeneralRe: How does Google Chrome Installer gets installed with UAC Prompt Pin
Raj Aryan 10012-May-11 6:09
Raj Aryan 10012-May-11 6:09 
AnswerRe: How does Google Chrome Installer gets installed with UAC Prompt Pin
Luc Pattyn1-May-11 22:57
sitebuilderLuc Pattyn1-May-11 22:57 
GeneralRe: How does Google Chrome Installer gets installed with UAC Prompt Pin
Raj Aryan 10011-May-11 23:25
Raj Aryan 10011-May-11 23:25 

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.