this looks better:
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void center(int); // center() func prototype
int draw(); /* whats this semicolon doing here? */
{
int i, j, count = 0, times = 19;
char x_mas = '^', *post = "||", star = '*';
// Set x_mas var default to '^'
char name[20];
puts("Enter your name: ");
gets(name);
/* puts("Enter a symbol to represent pine spikes: ");*/
x_mas = '$';
for(i=0;i<20;i++)
{
// Block to handle 0 (star on tree)
if(i==0 && times == 19)
{
center(times);
printf("%c", star);
}
--times; // Keep decrementing times to make it
center(times); // work with the index num i
if(i == 1)
{
center((++times + ++times)); // times remains 18.
printf("%c%c\n", x_mas, x_mas); // 36 spaces for index num = 1
continue;
}
else if(i > 1)
{
for(j=0;j<i;j++)
{
printf("%c%c", x_mas, x_mas);
}
if(j == i)
putchar('\n');
}
}
times = 19;
while(count != 2)
{
count++;
center(times - 1); // Space until reach 18th x_mas char
printf("%s\n", post); // so calculate to get 18 (times - 1)
}
printf("%s,WELCOME TO WHO WANTS TO BE A MILLIONAIRE GAME!\n", name);
/* system("PAUSE");*/
return 0; /* this function will always return a 0, is this what you want? */
}
void center(int times)
{
int i;
char space = ' ';
for(i=0;i<times;i++)
printf("%c", space);
printf("%c%c", space, space);
}