#ifndef __GNUC__
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef __GNUC__
#define snprintf _snprintf
#endif
static char *btrieveFileName = (char *)"squaresAndSquareRoots.btr";
#define MIN_X 0
#define MAX_X 255
#define RECORD_FIXED_SIZE 11
#define RECORD_MAXIMUM_VARIABLE_SIZE 1024
#define RECORD_MAXIMUM_TOTAL_SIZE (RECORD_FIXED_SIZE + RECORD_MAXIMUM_VARIABLE_SIZE)
#pragma pack(1)
typedef struct {
struct
{
uint8_t x;
uint16_t xSquared;
double xSquareRoot;
} fixed;
char text[RECORD_MAXIMUM_VARIABLE_SIZE];
} record_t;
#pragma pack()
typedef uint8_t _key_t;
{
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
leave:
return status;
}
{
{
goto leave;
}
leave:
return status;
}
{
int i;
record_t record;
for (i = MIN_X; i <= MAX_X; i++)
{
record.fixed.x = (uint8_t)i;
record.fixed.xSquared = (uint16_t)(i * i);
record.fixed.xSquareRoot = sqrt((double)i);
snprintf(record.text, RECORD_MAXIMUM_VARIABLE_SIZE, "The square of %d is %d and its square root is %f.", record.fixed.x, record.fixed.xSquared, record.fixed.xSquareRoot);
record.text[RECORD_MAXIMUM_VARIABLE_SIZE - 1] = '\0';
{
goto leave;
}
}
leave:
return status;
}
{
{
goto leave;
}
leave:
return status;
}
{
{
goto leave;
}
leave:
return status;
}
{
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
leave:
return status;
}
{
record_t record;
{
goto leave;
}
printf("record: (%u, %u, %f, %s)\n", record.fixed.x, record.fixed.xSquared, record.fixed.xSquareRoot, record.text);
leave:
return status;
}
int
main(int argc, char *argv[])
{
_key_t key;
uint64_t integerValue;
if (argc != 2)
{
printf("Usage: %s uint8_value\n", argv[0]);
goto leave;
}
integerValue = atoi(argv[1]);
if ((integerValue < MIN_X) || (integerValue > MAX_X))
{
printf("Usage: %s uint8_value\n", argv[0]);
goto leave;
}
key = (_key_t)integerValue;
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
leave:
return 0;
return 1;
}