Can't run this program

It's the solution of the exercise given in the book. I get these errors:
- subscript requires array or pointer type
- error C2056: illegal expression
- error C2466: cannot allocate an array of constant size 0
- error C2143: syntax error: missing ']' before '='
- warning C4047: 'initializing': 'int' differs in levels of indirection from 'char [5]'
- warning C4047: 'initializing': 'int' differs in levels of indirection from 'char [4]'
- warning C4047: 'initializing': 'int' differs in levels of indirection from 'char [6]'
- arning C4477: 'printf' : format string '%s' requires an argument of type 'char *', but variadic argument 1 has type 'int'

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  #include <stdio.h>
#include <conio.h>
int main(void)
{
	char digits[10[10] =
	{
		"zero", "one",
		"two", "three",
		"four", "five",
		"six", "seven",
		"eight", "nine"
	};
	char num;
	printf("Enter number: ");
	num = _getche();
	printf("\n");
	num = num - '0';
	if (num >= 0 && num < 10)
		printf("%s", digits[num]);
	return 0;
}
line 5: missing closing bracket, it should be char digits[10][10] = //...
conio.h is not standard.

By the way, the error message should point you to the line causing the error, don't remove that information from your post. If it just happen that your IDE or compiler omits them, then consider to change them.
Last edited on
Topic archived. No new replies allowed.