Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Linked Lists in C
#8
ok, ive got most of it working. Only 2 things i have wrong atm, I cant get the compare function to really work at all, and I'm not sure how to get it to stop printing 0's if they are unnecessary, so 1000-999 shows up as 0001.

i have this for the compare so far:
Code:
int compare(struct integer *p, struct integer *q)
{
    
    int j;
    
    while  (p != NULL){
           if(q==NULL){
             return 1;}
             else if (q!=NULL){
                          if (p>q){
                                   j=1;}
                          else if (p<q){
                                   j= -1;}
                          else if (p==q){
                                   j= 0;}
                                   }
             p= p->next;
             q= q->next;
            
            
             }
            
            
return (j);            
}


it works if the one number is more digits then the other, but if they are the same number of digits it acts up. Dont know how im going to get it to work with 1000 and like 1001.
Reply


Messages In This Thread
Linked Lists in C - by Sivrat - 2010-09-14, 02:38 PM
Linked Lists in C - by Fiel - 2010-09-14, 02:41 PM
Linked Lists in C - by Sivrat - 2010-09-14, 02:50 PM
Linked Lists in C - by Fiel - 2010-09-14, 03:00 PM
Linked Lists in C - by Stereo - 2010-09-14, 09:37 PM
Linked Lists in C - by Sivrat - 2010-09-15, 11:54 AM
Linked Lists in C - by Stereo - 2010-09-15, 03:44 PM
Linked Lists in C - by Sivrat - 2010-09-15, 05:29 PM
Linked Lists in C - by Stereo - 2010-09-15, 06:10 PM
Linked Lists in C - by Sivrat - 2010-09-15, 07:49 PM
Linked Lists in C - by Stereo - 2010-09-15, 08:10 PM
Linked Lists in C - by Sivrat - 2010-09-15, 08:17 PM
Linked Lists in C - by Stereo - 2010-09-15, 08:39 PM
Linked Lists in C - by Sivrat - 2010-09-15, 08:45 PM
Linked Lists in C - by Stereo - 2010-09-15, 08:54 PM
Linked Lists in C - by Sivrat - 2010-09-15, 09:02 PM
Linked Lists in C - by Sivrat - 2010-09-15, 10:56 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)