Click here to Skip to main content
15,921,990 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: CRC Pin
varunpandeyengg9-May-11 22:21
varunpandeyengg9-May-11 22:21 
QuestionProblem with VC toolbox Pin
Cold_Fearing_Bird8-May-11 16:47
Cold_Fearing_Bird8-May-11 16:47 
AnswerRe: Problem with VC toolbox Pin
Hans Dietrich8-May-11 17:01
mentorHans Dietrich8-May-11 17:01 
QuestionRegister ocx in Windows7 Pin
Max++8-May-11 14:06
Max++8-May-11 14:06 
AnswerRe: Register ocx in Windows7 Pin
Richard Andrew x648-May-11 14:20
professionalRichard Andrew x648-May-11 14:20 
AnswerRe: Register ocx in Windows7 Pin
pandit848-May-11 21:10
pandit848-May-11 21:10 
AnswerRe: Register ocx in Windows7 Pin
Malli_S9-May-11 0:41
Malli_S9-May-11 0:41 
AnswerRe: Register ocx in Windows7 Pin
Max++9-May-11 15:12
Max++9-May-11 15:12 
Question"Ending program ... please wait" - what system message needs a response ? Pin
Still learning how to code8-May-11 8:56
Still learning how to code8-May-11 8:56 
AnswerRe: "Ending program ... please wait" - what system message needs a response ? Pin
Code-o-mat8-May-11 9:28
Code-o-mat8-May-11 9:28 
AnswerRe: "Ending program ... please wait" - what system message needs a response ? Pin
Luc Pattyn8-May-11 9:45
sitebuilderLuc Pattyn8-May-11 9:45 
GeneralRe: "Ending program ... please wait" - what system message needs a response ? Pin
Still learning how to code8-May-11 11:16
Still learning how to code8-May-11 11:16 
Questionapplication messaging Pin
Krauze7-May-11 22:20
Krauze7-May-11 22:20 
AnswerRe: application messaging Pin
Richard MacCutchan7-May-11 23:33
mveRichard MacCutchan7-May-11 23:33 
GeneralRe: application messaging Pin
barneyman7-May-11 23:51
barneyman7-May-11 23:51 
GeneralRe: application messaging Pin
Richard MacCutchan8-May-11 0:08
mveRichard MacCutchan8-May-11 0:08 
QuestionRe: application messaging Pin
David Crow9-May-11 3:16
David Crow9-May-11 3:16 
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;

                }
            }

        }
}

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.