// Drawing Stuff

#include <stdio.h>
#include <conio.h>

#define SPLAT 0xDB

#define TR 0xBF
#define TL 0xDA
#define	BR 0xD9
#define BL 0xC0
#define HB 0xC4
#define VB 0xB3

void drawHBar(int x, int y, int length, int color);
void drawBox(int x, int y, int height, int width, int color, char* title);
void drawLabel(char* str, int x, int y, int txtColor, int txtBackground);

void drawLabel(char* str, int x, int y, int txtColor, int txtBackground) {
	textcolor(txtColor);
	textbackground(txtBackground);
	gotoxy(x, y);

	while (*str != '\0') {
		putchar(*str);
		str++;
	}

	textbackground(BLACK);
}

void drawBox(int x, int y, int height,
			 int width, int color,
			 char* title) {
	int i;

	textcolor(color);

	height--;
	width--;

	// splat top left, bottom left
	gotoxy(x, y);
	putchar(TL);
	gotoxy(x, y + height);
	putchar(BL);

	// splat both horz. bars
	for (i = 1; i < width; i++) {
		gotoxy(x + i, y);
		putchar(HB);
		gotoxy(x + i, y + height);
		putchar(HB);
	}

	//splat the right corners
	gotoxy(x + width, y);
	putchar(TR);
	gotoxy(x + width, y + height);
	putchar(BR);

	for (i = 1; i < height; i++) {
		gotoxy(x, y + i);
		putchar(VB);
		gotoxy(x + width, y + i);
		putchar(VB);
	}

	drawLabel(title, x + 1, y, WHITE, BLUE);
}


void drawHBar(int x, int y, int length, int color) {


	int i;

	textcolor(color);

	for (i = 0; i < length; i++) {
		gotoxy(x + i, y);
		putchar(SPLAT);
	}

	return;
}

// Driver

#include <stdio.h>
#include <conio.h>

#define LITEHATCH 176
#define MEDHATCH 177
#define DARKHATCH 178

#define SPLAT 0xDB

void drawBox(int x, int y, int height, int width, int color, char* title);
void drawHBar(int x, int y, int length, int color);
void drawLabel(char* str, int x, int y, int txtColor, int txtBackground);
void echoData(void);

void main(void) {


	double x = 3.3;
	double y = 33.0;
	double z = x * 10.0;

	int i = ((z) == y);

	printf("Equal? %i \n", i);

	clrscr();
	//textcolor(YELLOW);

	/*
	for(i = 0; i < 10; ++i) {
    		gotoxy(i, i);
    		printf("%c", LEFT_T);
	}

	for(; i < 20; ++i) {
    		gotoxy(i, i);
    		printf("%c", DARKHATCH);
	}
	*/

	drawBox(1, 1, 25, 80, YELLOW, "Fun");
	drawBox(5, 5, 20, 60, WHITE, "What");
	//drawHBar(10, 5, 10, BLUE);
	drawHBar(1, 20, 40, YELLOW);
	//drawHBar(60, 1, 15, WHITE);
	//drawHBar(1, 24, 80, MAGENTA);
	//drawHBar(1, 25, 80, MAGENTA);
	gotoxy(1,1);
	//drawHBar(10, 5, 10, BLUE);

	echoData();
	getchar();

}

// Sample File reader

#include <stdio.h>


void echoData() {

	FILE* theFile;
	int month;
	int year;
	double price;

	theFile = fopen("c:\\data.txt", "r");

	while ( fscanf(theFile, "%d %d %lg",&month, &year, &price) != EOF) {
        	printf("Month = %i, Year = %i, Price = %f\n", month, year, price);
    	}

	fclose(theFile);
}