// Text2C
// Small program that takes a line of text can convert to a C hexidecimal table.
// This code can then be pasted into your program.

// Version 1.0
// Date 22:25 08/10/2016
// By Ben a.k.a DreamVB

#include <iostream>

int main(int argc, char *argv[]){
	char *s0 = "This will be converted to a C hexidecimal TableA";
	char TEXT[1024];
	int i = 0;
	int j = 0;
	int len = 0;
	int c = 0;

	printf("Enter some text: ");
	//Get the inputted text
	gets(TEXT);
	//Resize the s0 to hold text.
	s0 = (char*)malloc(strlen(TEXT));
	//Copy from TEXT to s0
	strcpy(s0, TEXT);

	//Get source length
	len = strlen(s0);
	
	//Clear the screen.
	system("cls");

	printf("//Place this code into your C++ project.\n");
	printf("int i = %d;\n", 0);
	printf("const int size = %d;\n", len);
	printf("const char TEXTDATA[] = {\n",len);

	while (i < len){
		//Get char
		c = s0[i];
		//Print hexidecimal value.
		printf("0x%x, ",c);
		//Used for the line breaks.
		j = (j + 1) % 6;

		if (j == 0){
			//Append line break
			printf("\n");
		}
		//INC counter.
		i++;
	}
	//Print ending.
	printf("0};\n");
	//Print code to print out generated hex table
	printf("while (i < size ){printf(");
	printf("%c",'\"');
	printf("%c",'%');
	printf("c");
	printf("%c", '\"');
	printf(", TEXTDATA[i]);i++;}\n\n");

	system("pause");
	return 0;
}