//Code to try and convert a number to a string and then concatenate it with
//another string

#include <stdio.h>              /* Standard Input Output */
#include <math.h>               /* Standard Math stuff   */
#include <stdlib.h>		/* Standard Library stuff */
#include <string.h>

int main(){
float number=5.0;	        /* Number to be converted */
int decimal,decimal2;
int sign,sign2;
int length=4;
char string[]="Phase.out_";	/* Teststring for concatenation */
char *Ecvt,*Ecvt2;		/* This is pointless since the pointer is */
				/* overwritten */
char b[3];			/* Need to copy string so not overwritten */
char c[3];
char *a;
Ecvt = ecvt(23333.23,8,&decimal,&sign);
strcpy(b,Ecvt);
Ecvt2 = ecvt(245.99,8,&decimal2,&sign2);
strcpy(c,Ecvt2);

printf("Here's the contents of 233.23 copied to b:\t%s\n",b);
printf("Number of points before decimal=%d\n",decimal);
printf("Sign=%d\n",sign);
printf("Here're the points after the decimal\t%s\n",&Ecvt[0]);
printf("Here's the pointer to a char:\t%d\n",a);
printf("%s\n",&Ecvt2[0]);
printf("%s\n",c);

/*Attempt to use Malloc*/
char* AStr;
if ((AStr = malloc(sizeof(char) * 11 )) == NULL) {
   printf("Bad Allocation\n");
}
strcpy(AStr,string);
printf("Here's The String With Malloc:\t%s\n",AStr);
char test[] ="TestString";
strcat(AStr,test);
printf("Here's The Concatenated Version:\t%s\n",AStr);
free(AStr);
printf("Here's The String After Free:\t%s\n",AStr);
}


