Click here to Skip to main content
15,905,563 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: application messaging Pin
barneyman9-May-11 3:39
barneyman9-May-11 3:39 
GeneralRe: application messaging Pin
Code-o-mat8-May-11 9:35
Code-o-mat8-May-11 9:35 
Questionlzma on GPU Pin
crotaphiticus7-May-11 20:12
crotaphiticus7-May-11 20:12 
AnswerRe: lzma on GPU Pin
Code-o-mat8-May-11 6:22
Code-o-mat8-May-11 6:22 
GeneralRe: lzma on GPU Pin
crotaphiticus8-May-11 7:54
crotaphiticus8-May-11 7:54 
GeneralRe: lzma on GPU Pin
Code-o-mat8-May-11 9:39
Code-o-mat8-May-11 9:39 
GeneralRe: lzma on GPU Pin
crotaphiticus8-May-11 12:33
crotaphiticus8-May-11 12:33 
Questionabout multi linked list Pin
quartaela7-May-11 9:44
quartaela7-May-11 9:44 
hi there i have discussed my problems about multi linked list thread
http://www.codeproject.com/Messages/3876300/implementing-multi-linked-list-correctly_.aspx

but i recognize that it coldn't solved. my problem was about implementing a multi linked list which your list implemented by more than one cases. for example by first name or last name. so it have two header and tail pointers. the adding and building the list operations are succesfully working. and there is not a problem when i delete a node by "first_name" and when i search him again, the output is "not found". but when i search him by his "last_name" (so i using header pointer of last name here) the output becomes "person exist". i hope i explain my problem understandable : ). so i appreciated if you can help me.

here is my structures

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* fn_pre;
    struct node* ln_next;
    struct node* ln_pre;
    struct node* birdat_next;
    struct node* birdat_pre;

} NODE;

typedef struct {

    int fn_count;
    int ln_count;

    NODE* fn_head;
    NODE* ln_head;
    
    NODE* fn_tail;
    NODE* ln_tail;

}LIST;


and here is the block i call adding functions for name and surname;

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 of course my add functions;
void add_fn_Node(LIST* list, NODE* pnew_stu) {

    NODE* temp = list->fn_head;

    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 ) { // Condition for add before the first node

                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 ) { // Condition for add middle

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

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

                        list->fn_count++;

                        return;
                    }

                        temp = temp->fn_next;

                    }

                if ( temp->fn_next == NULL ) { // Condition for add to end

                    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( 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 ) { // Condition for add before the first node

                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 ) { //Condition for add middle

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

                        pnew_stu->ln_next = temp->ln_next;
                        pnew_stu->ln_pre = temp;
                        temp->ln_next->ln_pre = pnew_stu;
                        temp->ln_next = pnew_stu;
                        
                        list->ln_count++;

                        return;
                    }

                        temp = temp->ln_next;

                    }

                if ( temp->ln_next == NULL ) { // Condition for add to end

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

                    list->ln_tail = pnew_stu;

                    list->ln_count++;

                    return;

                }
            }

        }
}

AnswerRe: about multi linked list Pin
Luc Pattyn7-May-11 10:26
sitebuilderLuc Pattyn7-May-11 10:26 
GeneralRe: about multi linked list Pin
quartaela7-May-11 11:09
quartaela7-May-11 11:09 
GeneralRe: about multi linked list Pin
barneyman7-May-11 15:53
barneyman7-May-11 15:53 
GeneralRe: about multi linked list Pin
quartaela8-May-11 3:41
quartaela8-May-11 3:41 
GeneralRe: about multi linked list Pin
barneyman8-May-11 3:51
barneyman8-May-11 3:51 
QuestionMSVCR100.dll error, debugger_hook_dummy = 0 Pin
mikael.peterson6-May-11 22:59
mikael.peterson6-May-11 22:59 
AnswerRe: MSVCR100.dll error, debugger_hook_dummy = 0 Pin
Luc Pattyn7-May-11 2:28
sitebuilderLuc Pattyn7-May-11 2:28 
GeneralRe: MSVCR100.dll error, debugger_hook_dummy = 0 Pin
mikael.peterson7-May-11 23:18
mikael.peterson7-May-11 23:18 
AnswerRe: MSVCR100.dll error, debugger_hook_dummy = 0 Pin
kellymac10-Jan-12 12:20
kellymac10-Jan-12 12:20 
QuestionProblem Opening Email when using InvokeHelper in C++ Pin
Member 29729926-May-11 5:00
Member 29729926-May-11 5:00 
AnswerRe: Problem Opening Email when using InvokeHelper in C++ Pin
Richard MacCutchan6-May-11 5:36
mveRichard MacCutchan6-May-11 5:36 
GeneralRe: Problem Opening Email when using InvokeHelper in C++ Pin
Member 29729926-May-11 6:15
Member 29729926-May-11 6:15 
GeneralRe: Problem Opening Email when using InvokeHelper in C++ Pin
Richard MacCutchan6-May-11 23:01
mveRichard MacCutchan6-May-11 23:01 
GeneralRe: Problem Opening Email when using InvokeHelper in C++ Pin
Member 29729926-May-11 23:11
Member 29729926-May-11 23:11 
GeneralRe: Problem Opening Email when using InvokeHelper in C++ Pin
Richard MacCutchan7-May-11 0:33
mveRichard MacCutchan7-May-11 0:33 
GeneralRe: Problem Opening Email when using InvokeHelper in C++ Pin
Member 29729927-May-11 2:07
Member 29729927-May-11 2:07 
GeneralRe: Problem Opening Email when using InvokeHelper in C++ Pin
Richard MacCutchan7-May-11 5:22
mveRichard MacCutchan7-May-11 5:22 

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.