Christmas Card

Couple questions:
1. Why is my bottom border not centered and actually displaying the underscores? And how can I be using strlen to make the bottom border correct?
2. I am stumped on how to create the bottom trunk of the tree. Do I just need to create another loop that subtracts from the lowest row?
3. When I want to start writing to a file, do I have the correct first lines of code?
4. Why,when I put in a row count of 60, does the entire program fail to correctly output a tree?

________________________________________________________________________________

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <stdio.h>
#include <string.h>


int main ()
{
//Variable declarations
char myString[75];
int choice = 0;
char FileName1[75];
int i;
int space;
int rows;
int k=0;
FILE *fp1;

//Ask for recipient
printf("Please enter recipient: ");
scanf("%s", &myString);
strlen("myString");

//Ask user to pick between outputting to stDout or file
printf("Please enter a number greater than zero to output to the stdOut \n or enter a number less than zero to output to a file: ");
scanf("%d", &choice);

	//Displaying to stdOut
	if (choice > 0){
	printf("Please enter the number of rows: ");
	scanf("%d", &rows);

		//Christmas Tree Build
		//Top of border
		for (i=1;i<=2*rows+1;++i)
		{
		printf("_");
		}
		printf("\n");

		//Chrsitmas Tree Build
		printf("|");
		for (i=1;i<=rows;++i)
		{
		for(space=1;space<=rows-i;++space)
		{
		printf(" ");
		}
		while(k!=2*i-1)
		{
		printf("*");
		++k;
		}
		for(space=1;space<=rows-i;++space)
		{
		printf(" ");
		}
		k=0;
		printf("|\n|");
		}
		//Bottom of border
		//for (i=1;i<=(2*rows+1)-(19+ , myString);++i)
		{
		printf("_Happy Holidays:%s!!__|",myString);
		}
		printf("\n");

	//Output to a file
	}else{
	printf("Please enter a name for your file. \n");
	scanf("%s", &FileName1);
	fp1 = fopen ("C:\\FileName1.txt", "w");
	printf("Your Christmas card was placed here at -> C:\\%s                      ", FileName1); 
	}


return 0;
}

Last edited on
Topic archived. No new replies allowed.