STRUCT


////****************************SUB'S BY H.STOLPE************************/////
////*****SMALL PROGRAM DISPLAYING THE USE OF STRUC& ARRAYS**************/////
////*****THE STRUCTURE HOLDS INFO ON SUB's*******************************/////


#include <stdio.h>

///structure definition
struct SUBMARINE 
{
char *id;
int  comp;
double lenght;
int  depl;
int speed;
char *weapons[4];
};


int main(int wc)
{
//defining the structure 
struct SUBMARINE *spek;
//set memory adress where the pointer should point
///spek=(struct SUBMARINE*)malloc(sizeof(struct SUBMARINE));

//attching values to the structur members
spek->id="Los Angeles Class";
spek->comp=127;
spek->lenght=109.8;
spek->depl=6080;
spek->speed=31;
spek->weapons[1]= "MK48 ADCAP Torpedo";
spek->weapons[2]= "Harpoon Missile";
spek->weapons[3]= "TASM Tomahawk Cruise Missile";
spek->weapons[4]= "TLAM Tomahawk Cruise Miassile";

///accessing members & displaying information
printf("Submarine Class: %s \n",spek->id);
printf("Complement: %d \n",spek->comp);
printf("Lenght: %f m \n",spek->lenght);
printf("Displacement: %d tonns surfaced \n",spek->depl);
printf("Max speed: %d knots \n\n",spek->speed);
printf("Weapons carried:\n");

///displaying array information
for (wc=1;wc<4;wc++)
	{
	printf("weapon type: %s \n",spek->weapons[wc]);
	}
getch();
return(0);
}