Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#define A 100
#define SIZE 2
typedef struct{
float Fish;
float Cotton;
}Goods_g;
typedef struct{
char Sydney[10]; /*!! you need more that a char for a string */
}Ports_p;
int Sydney(Goods_g *G, Ports_p *P, float variables[]);
int main()
{
Goods_g G;
Ports_p P; /*!! note - NOT POINTERS here */
char name[A];
int i;
int x=1000; /*!! this is UNUSED */
int j;
float variables[SIZE];
printf("Please enter your name: ");
scanf("%s",name); /*!! No & here, name is an array */
printf("Please select which pont you want to start in: ");
scanf("%d",&i);
if(i==1)
printf("Welcome to Sydney\n");
if(i>1 || i<1)
printf(" you must enter 1\n");
srand((unsigned)time(NULL));
for (j=0; j<2; j++)
variables[j] = (rand()%26)/14.0f;
strcpy( P.Sydney, "Sydney" );
Sydney(&G, &P, variables); /*!! Note - make POINTERS here */
return 0;
}
int Sydney(Goods_g *G, Ports_p *P, float variables[])
{
G->Fish = 50*variables[0]; /*!! you used == here, you meant = */
G->Cotton = 80*variables[1];
printf("Welcome to %s\n",P->Sydney);
printf("The prices for the material is as follows\n");
printf("Fish=%f\n", G->Fish);
printf("Cotton=%f\n", G->Cotton);
return 0;
}