Ok, I found several of the errors and compiled your program successfully.
First, you need to typedef the structure so that you can use frieghtor and planetoids to create other structures.
Code:
/**************************************************
* Header file for ..\database\alpha\000001\alpha *
**************************************************/
#ifdef RAND_MAX
#undef RAND_MAX
#define RAND_MAX 0x3
#endif
#define dl double long
typedef struct freighter {
char *name;
int max_fuel;
int fuel;
int max_cargo,cargo;
int cargo_type;
int speed;
int dest;
int x,y;
dl money;
} freighter;
typedef struct planetoids {
int p1x,p2x,p3x;
int p1y,p2y,p3y;
int p1s,p2s,p3s;
float rate1,rate2,rate3;
} planetoids;
Also RAND_MAX was already defined so what you do is check to see if it is defined. If it is you undefine it and redefine it to your value.
In the main file you has several errors. First, if you want to set a string a value you need to use strcpy you cannot just say:
Code:
Name = "Gamma"; //Wrong
strcpy(Name, "Gamma"); //Correct
Second you use freightor.maxfuel when the name of the variable in the structure is friegtor.max_fuel. The compiler cannot tell the difference.
When you are using a pointer to a structure you need to use "->"
Code:
freightor_a.fuel = 5 //WRONG
freightor_a->fuel = 5 //CORRECT
Here is the main source file:
Code:
/* --- The following code comes from C:\lcc\lib\wizard\textmode.tpl. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include "mud1.h"
void Usage(char *programName)
{
fprintf(stderr,"%s usage:\n",programName," /start");
/* Modify here to add your usage message when the program is
* called without arguments */
}
/* returns the index of the first argument that is not an option; i.e.
does not start with a dash or a slash
*/
int HandleOptions(int argc,char *argv[])
{
int i,firstnonoption=0;
for (i=1; i< argc;i++) {
if (argv[i][0] == '/' || argv[i][0] == '-') {
switch (argv[i][1]) {
/* An argument -? means help is requested */
case '?':
Usage(argv[0]);
break;
case 'h':
case 'H':
if (!stricmp(argv[i]+1,"help")) {
Usage(argv[0]);
break;
}
/* If the option -h means anything else
* in your application add code here
* Note: this falls through to the default
* to print an "unknow option" message
*/
/* add your option switches here */
default:
fprintf(stderr,"unknown option %s\n",argv[i]);
break;
}
}
else {
firstnonoption = i;
break;
}
}
return firstnonoption;
}
int main(int argc,char *argv[])
{
if (argc == 1) {
/* If no arguments we call the Usage routine and exit */
Usage(argv[0]);
return 1;
}
/* handle the program options */
HandleOptions(argc,argv);
/* The code of your application goes here */
if (stricmp(argv[5],"/start")) {
freighter gamma;
freighter *freighter_a;
planetoids planets;
planetoids *starport;
freighter_a = γ
starport = &planets;
if (freighter_a && starport) {
strcpy(freighter_a->name, "Gamma");
freighter_a->max_fuel = 2000;
freighter_a->fuel = freighter_a->max_fuel;
freighter_a->max_cargo = 150;
freighter_a->cargo = 0;
freighter_a->cargo_type = 0;
freighter_a->speed = 100;
freighter_a->dest = 0;
freighter_a->x = 0;
freighter_a->y = 0;
freighter_a->money = 5000;
starport->p1x = 0;
starport->p1y = 0;
starport->p1s = 200;
starport->p2x = 150;
starport->p2y = -50;
starport->p2s = 50;
starport->p3x = 100;
starport->p3y = 100;
starport->p3s = 150;
starport->rate1 = 0.5;
starport->rate2 = 0.8;
starport->rate3 = 1.25;
}
printf("This is a simple database test along with AI that uses something similar to fuzzy logic.");
printf("The freighter %s will move between three planets at it's own descretion, hauling cargo back and fourth.", freighter_a->name);
}
return 0;
}
You also were using fprintf way wrong.
Hope this helps.
- Sean