Is Linking array content with a string possible?


I am trying to write a code for a simple calendar/to-do list program which prompts the user to enter the desired month, and when the user does so, the calendar for the selected month comes up on screen. next, the user enters an appointment for any date of that month and then his appointment is stored in a string linked to that date. The date then turns into a different shade of color to show that it has a linked appointment. I am strictly limited to arrays and strings, not even allowed to use structures or functions. I got stuck at linking a date with a specific appointment, how do I do this? do I need to allocate dynamic memory for every appointment? Here is the code, any help would be greatly appreciated.
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
  #include<iostream.h>
#include<conio.h>
#include<string.h>
#include<process.h>
void main()
{
	clrscr();
	int month,day[31],date;
	char note[100],response;
	cout<<"Enter the month of 2015 you would like to access:\t";
	cin>>month;
	switch (month){
	case 1:
	cout<<"\n\n\t\tJANUARY 2015";
	cout<<"\nMon\tTue\tWed\tThur\tFri\tSat\tSun\n";
	for(int i=-2;i<32;i++)
	{
	   if(i<1)
	   cout<<"\t";
	   else
	   {
	   day[i]=i;
	   if(i==5||i==12||i==19||i==26)
	   cout<<endl;
	   else{}
	   cout<<day[i]<<"\t";
	   }
	}
	break;
	case 2:
	cout<<"\n\n\t\tFEBRUARY 2015";
	cout<<"\nMon\tTue\tWed\tThur\tFri\tSat\tSun\n";
	for(i=-5;i<29;i++)
	{
	    if(i<1)
	    cout<<"\t";
	    else
	    {
	    day[i]=i;
	    if(i==2||i==9||i==16||i==23)
		cout<<endl;
		else{}
		cout<<day[i]<<"\t";
	    }
	    }
	    break;
	case 3:
	cout<<"\n\n\t\tMARCH 2015";
	cout<<"\nMon\tTue\tWed\tThur\tFri\tSat\tSun\n";
	for(i=-5;i<32;i++)
	{
	    if(i<1)
	    cout<<"\t";
	    else
	    {
	     day[i]=i;
	     if(i==2||i==9||i==16||i==23||i==30)
	     cout<<endl;
	     else{}
	     cout<<day[i]<<"\t";
	    }
	    }
	    break;
	 case 4:
	 cout<<"\n\n\t\tAPRIL 2015";
	 cout<<"\nMon\tTue\tWed\tThur\tFri\tSat\tSun\n";
	 for(i=-1;i<31;i++)
	 {
	    if(i<1)
	    cout<<"\t";
	    else
	    {
	    day[i]=i;
	    if(i==6||i==13||i==20||i==27)
	    cout<<endl;
	    else{}
		cout<<day[i]<<"\t";
	    }
	    }
	    break;
	 case 5:
	 cout<<"\n\n\t\tMAY 2015";
	 cout<<"\nMon\tTue\tWed\tThur\tFri\tSat\tSun\n";
	 for(i=-3;i<32;i++)
	 {
	    if(i<1)
	    cout<<"\t";
	    else
	    {
	    day[i]=i;
	    if(i==4||i==11||i==18||i==25)
	    cout<<endl;
	    else{}
	    cout<<day[i]<<"\t";
	    }
	    }
	    break;
	 case 6:
	 cout<<"\n\n\t\tJUNE 2015";
	 cout<<"\nMon\tTue\tWed\tThur\tFri\tSat\tSun\n";
	 for(i=1;i<31;i++)
	 {
	    day[i]=i;
	    if(i==1||i==8||i==15||i==22||i==29)
	    cout<<endl;
	    else{}
	    cout<<day[i]<<"\t";
	    }
	    break;
	 case 7:
	 cout<<"\n\n\t\tJULY 2015";
	 cout<<"\nMon\tTue\tWed\tThur\tFri\tSat\tSun\n";
	 for(i=-1;i<32;i++)
	 {
	    if(i<1)
	    cout<<"\t";
	    else
	    {
	    day[i]=i;
	    if(i==6||i==13||i==20||i==27)
	    cout<<endl;
	    else{}
	    cout<<day[i]<<"\t";
	    }
	    }
	    break;
	case 8:
	 cout<<"\n\n\t\tAUGUST 2015";
	 cout<<"\nMon\tTue\tWed\tThur\tFri\tSat\tSun\n";
	 for(i=-4;i<32;i++)
	 {
	    if(i<1)
	    cout<<"\t";
	    else
	    {
	    day[i]=i;
	    if(i==3||i==10||i==17||i==24||i==31)
	    cout<<endl;
	    else{}
	    cout<<day[i]<<"\t";
	    }
	    }
	   break;
	case 9:
	cout<<"\n\n\t\tSEPTEMBER 2015";
	cout<<"\nMon\tTue\tWed\tThur\tFri\tSat\tSun\n";
	for(i=0;i<31;i++)
	{
	    if(i<1)
	    cout<<"\t";
	    else
	    {
	    day[i]=i;
	    if(i==7||i==14||i==21||i==28)
	    cout<<endl;
	    else{}
	    cout<<day[i]<<"\t";
	    }
	    }
	    break;
	case 10:
	cout<<"\n\n\t\tOCTOBER 2015";
	cout<<"\nMon\tTue\tWed\tThur\tFri\tSat\tSun\n";
	for(i=-2;i<32;i++)
	{
	    if(i<1)
	    cout<<"\t";
	    else
	    {
	    day[i]=i;
	    if(i==5||i==12||i==19||i==26)
	    cout<<endl;
	    else{}
	    cout<<day[i]<<"\t";
	    }
	    }
	    break;
	case 11:
	cout<<"\n\n\t\tNOVEMBER 2015";
	cout<<"\nMon\tTue\tWed\tThur\tFri\tSat\tSun\n";
	for(i=-5;i<31;i++)
	{
	    if(i<1)
	    cout<<"\t";
	    else
	    {
	    day[i]=i;
	    if(i==2||i==9||i==16||i==23||i==30)
	    cout<<endl;
	    else{}
	    cout<<day[i]<<"\t";
	    }
	    }
	    break;
	 case 12:
	 cout<<"\n\n\t\t\tDECEMBER 2015";
	 cout<<"\nMon\tTue\tWed\tThur\tFri\tSat\tSun\n";
	  for(i=0;i<32;i++)
	 {
	    if(i<1)
	    cout<<"\t";
	    else
	    {
	    day[i]=i;
	    if(i==7||i==14||i==21||i==28)
	    cout<<endl;
	    else{}
	    cout<<day[i]<<"\t";
	    }
	    }
	    break;
	default:
	cout<<"Wrong Input";
	}
	cout<<"\n\n\nWould you like to add an appointment?\t";
	cin>>response;
	if(response=='N'||response=='n')
	cout<<"GOODBYE";
	else{
	cout<<"On what date would you like to add an appointment?";
	cin>>date;
	}
	cout<<"Please write your appointment here and enter '*' when you are done:\n";
	cin.get(note,100,'*');
	getch();
}
Last edited on
std::string appoinment[12][31];
Topic archived. No new replies allowed.