#1 (permalink)  
Old 10-29-05, 03:23 PM
ArChAnGeL_J ArChAnGeL_J is offline
Newbie Coder
 
Join Date: Oct 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Arrays

ok i'm getting some trouble with arrays and i need some help.
I have to read from a file... and i'm putting each number entered into an array.. i did that.. that's d easy part... so i have several arrays from that file alone.. the problem is i have to display the item id and the selling price sorted by selling price for all items. so how am i doing that? get alot of trouble doing this
Thx in advance for any help
Reply With Quote
  #2 (permalink)  
Old 10-29-05, 10:42 PM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
why not merge all the small arrays into one big array and then sort it?
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #3 (permalink)  
Old 10-31-05, 07:32 PM
ArChAnGeL_J ArChAnGeL_J is offline
Newbie Coder
 
Join Date: Oct 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
ok thx i'll try that.. ok lol this is sad but i need help in something else.. i'm having problems printin the highest and least values in an array.. i have a piece of code i tried and here it is:
int i=0;
int hi=0;
int lo=9999;
fscanf(f,"%d",&itemid[i]);
while (!feof(f)&&itemid[i]!=0)
{
fscanf(f,"%f",&costprice[i]);
fscanf(f,"%f",&sprice[i]);
fscanf(f,"%d",&squantity[i]);
fscanf(f,"%d",&quantitysold[i]);
fscanf(f,"%d",&itemid[i]);
}
if (costprice[i]>hi){
hi=costprice[i];
}
if (costprice[i]<lo){
lo=costprice[i];
}


printf("%d is the highest cost price\n",hi);
printf("\n%d is the least cost price",lo);
getch();

}
It's printin out the highest value fine.. but it's not printin the correct value for the least.. can anybody tell me what's wrong please?
Thanks in advance
Reply With Quote
  #4 (permalink)  
Old 11-07-05, 09:01 PM
ArChAnGeL_J ArChAnGeL_J is offline
Newbie Coder
 
Join Date: Oct 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Well.. nevermind.. got it out newayz..
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Arrays with sub arrays perleo PHP 1 09-30-05 07:15 PM
arrays and drop boxes minority JavaScript 1 09-06-05 01:14 PM
Can record arrays on database? mhs12grade1992 PHP 5 02-17-05 11:20 AM
arrays in functions Slypher PHP 3 01-30-05 05:36 AM
Arrays cebuy PHP 1 10-25-04 07:40 AM


All times are GMT -5. The time now is 04:34 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.