hey everyone im looking for some help i just started a programing unit and im not looking for poeple to do my work for me but i am looking for help... the program im writing randomly creates fish and adds them to an array but its ment to do this in a void function and i just dont understand that so if anyone could give some advice with maby some example code that i could understand you would help me out so much...ive tryed lookin through tutroials but im still comming up blank
here is my code ...its rather messy and for that im sorry...but its my first time programing
Code:
#define PERCHMAX 10000
//Defines Minimum Weight For ANy fish
#define MIN 500
//Declares Max Weight of basket
#define MAXWBASKET 15000
//Max Number Fish To Pick From
#define AviliableFish 4
struct fish{
char fishName[30];
char latinName[40];
int weight;
};
struct fishing{
int numberFish;
int totalWeight;
struct fish Basket[50];
};
typedef struct fish Fish;
typedef struct fishing Fishing;
#include "Fish.h"
//This Function is Designed to Imitate The Fishing Process
//This Function Prints The Results That The porgram Returns
int main(void){
//Prints Introduction then waits till user hits key to continue
printf("Welcome To The Fishing Program \n");
printf("This Program was Created By Shane Innes (2700508)\n");
Fishing *Basket;
void fishing(Fish *weight ,Fishing *Basket;);
init_array(s_array, n);
print_array(s_array,n);
//Pauses System and waits for a reply from user
system("PAUSE");
return 0;
// strcpy(a.fishName, "Shane Innes");
}
void fishing(Fishing *Basket, numberFishCaught)
{
//Pauses Program And waits for a keystroke
int totalweight ;
int numberFishCaught = 0 ;
Fish a,b,c,d;
Fishing Fishing;
//Creates a fishcheck
//x becomes total weight
int x ;
//Creates A random number Genrater based of the time
srand(time(0));
//Creates a while loop, While fish weight is less than max basket weight keep going
while ( x < MAXWBASKET){
int fishType;
fishType = ((rand()%AviliableFish)+ 1 ); //creates a random number between 1 and 4
switch (fishType) //Switch Statment Checks Values Agnsit Fishtype vairble
{
/* If expression resolves to 1, jump here */
case 1:
printf("case1");
a.fishName, "Australian Bass";
a.latinName, "Macquaria Novemaculeata";
int FishWeight;
FishWeight = ((rand()%AUSBASMAX)+ 1 );
a.weight = FishWeight;
if (FishWeight > 500 && FishWeight < AUSBASREC)
{
numberFishCaught = numberFishCaught + 1;
Fishing.numberFish = numberFishCaught;
Fishing.Basket[numberFishCaught]= a;
x = x + FishWeight;
printf("Caught : %s\n",a.fishName);
printf("Weight : %d\n",a.weight);
printf("Status : Was Put In Basket");
}
else if (FishWeight < 500 || FishWeight > AUSBASREC)
{
printf("Caught : %s\n",a.fishName);
printf("Weight : %d\n",a.weight);
printf("Status : Was release Back Into Stream");
}
break; /* break - cases the execution to jump out of the 'switch' block. */
/* If expression resolves to 2, jump here */
case 2:
printf("case2");
b.fishName, "Fish 2";
b.latinName, "Fish 2";
FishWeight = ((rand()%SHORTFINEELMAX)+ 1 );
a.weight = FishWeight;
if (FishWeight > 500 && FishWeight < SHORTFINEELREC)
{
numberFishCaught = numberFishCaught + 1;
Fishing.numberFish = numberFishCaught;
Fishing.Basket[numberFishCaught]= b;
x = x + FishWeight;
printf("Caught : %s\n",b.fishName);
printf("Weight : %d\n",b.weight);
printf("Status : Was Put In Basket");
}
else if (FishWeight < 500 || FishWeight > SHORTFINEELREC)
{
printf("Caught : %s\n",b.fishName);
printf("Weight : %d\n",b.weight);
printf("Status : Was release Back Into Stream");
}
break;
/* If expression resolves to 3, jump here */
case 3:
printf("case3");
c.fishName, "Fish 3";
c.latinName, "Fish 3";
FishWeight = ((rand()%EELCATFISHMAX)+ 1 );
a.weight = FishWeight;
if (FishWeight > 500 && FishWeight < EELCATFISHREC)
{
numberFishCaught = numberFishCaught + 1;
Fishing.numberFish = numberFishCaught;
Fishing.Basket[numberFishCaught]= c;
x = x + FishWeight;
printf("Caught : %s\n",c.fishName);
printf("Weight : %d\n",c.weight);
printf("Status : Was Put In Basket");
}
else if (FishWeight < 500 || FishWeight > EELCATFISHREC)
{
printf("Caught : %s\n",c.fishName);
printf("Weight : %d\n",c.weight);
printf("Status : Was release Back Into Stream");
}
break;
case 4:
printf("case4");
d.fishName, "Fish 4";
d.latinName, "Fish 4";
FishWeight = ((rand()%PERCHMAX)+ 1 );
a.weight = FishWeight;
if (FishWeight > 500 && FishWeight < PERCHREC)
{
numberFishCaught = numberFishCaught + 1;
Fishing.numberFish = numberFishCaught;
Fishing.Basket[numberFishCaught]= d;
x = x + FishWeight;
printf("Caught : %s\n",d.fishName);
printf("Weight : %d\n",d.weight);
printf("Status : Was Put In Basket");
}
else if (FishWeight < 500 || FishWeight > PERCHREC)
{
printf("Caught : %s\n",d.fishName);
printf("Weight : %d\n",d.weight);
printf("Status : Was release Back Into Stream");
}
break;
/* Any other value jumps here. */
default:
printf("A Error Occured This dose not effect results please ignore\n");
break;
}
}
}
void print_basket(Fishing *Basket, numberFishCaught){
int i;
for(i = 1; i < n; i++){
Basket[i]
Thanks agian if anyone could help out
in case i wasnt clear i wasnt sure how i should be declaring my void function as well as calling it in my main code