It worked every time until you changed an apple into an orange. Suddenly you aren't getting any apple juice.
When you use the
printf() function (and other like functions), you
must make sure that the
type of each argument matches the format specifier (that "%
n" thing).
To print a string, you must use "%s", and the argument must be a
char*
To print an integer, you must use "%d", and the argument must be an
int.
Etc.
You are trying to use "%s" to print a string, but your argument is a
char** (a pointer to a pointer to a character).
You are trying to use "%d" to print an integer, but your argument is a
int**.
Etc.
The same caveats hold true with
scanf().
So, to print a specific month, for example, use
printf( "%s", omonth[ 3 ] );
(I would presume this prints something like "April".)
To be fair, using the C formatted I/O routines
is confusing, because it is not straightforward.
Here are some hints:
1 2 3
|
/* read a string */
char s[ 100 ];
scanf( "%99s", s );
|
1 2 3
|
/* read an integer */
int n;
scanf( "%d", &n );
|
When dealing with arrays, you need to remember to dereference the item in the array.
1 2 3
|
/* read a string into the second element of an array of five strings */
char s[ 5 ][ 100 ];
scanf( "%99s", s[ 1 ] );
|
1 2 3
|
/* read an integer into the fifth element of an array of five integers */
int n[ 5 ];
scanf( "%d", &(n[ 4 ]) );
|
Hope this helps.