array month


how array month in c





#include "stdio.h"
#include "conio.h"
main ()
{
char month [12] = ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
printf("Month 1 : %c",month[0]);
printf("Month 2 : %c",month[1]);
printf("Month 3 : %c",month[2]);
printf("Month 4 : %c",month[3]);
printf("Month 5 : %c",month[4]);
printf("Month 6 : %c",month[5]);
printf("Month 7 : %c",month[6]);
printf("Month 8 : %c",month[7]);
printf("Month 9 : %c",month[8]);
printf("Month 10 : %c",month[9]);
printf("Month 11 : %c",month[10]);
printf("Month 12 : %c",month[11]);
getch ();
}

it error [Error] array must be initialized with a brace-enclosed initializer
Last edited on
help me! please!!!
Sorry but I dont understand your question. Could you please elaborate?
i have to use functions array by month Januarry-December

: then answer

month 1 : January
month 2 : February
month 3 : March
month 4 : April
month 5 : May
month 6 : June
month 7 : july
month 8 : Agust
month 9 : September
month 10 :October
month 11 :November
month 12 : December

help me please!!
1
2
3
4
5
6
7
8
9
10
11
12
13
int main()
{
	char months[12][20] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
	
	for (int i = 0; i < 12; i++)
	{
		printf("Month %d: %s \n",i+1, months[i]);
	}
	
	getchar();
	return 0;
	
}
thank you sir.
thank you sir.


If you want me to explain whats happening in the code feel free to ask.
how to months[i]);
Topic archived. No new replies allowed.