Originally Posted by
GReaper
The problem isn't that you can't point to it, you obviously can. But since it isn't static, thus being held temporarily on the stack, there's no guarantee that it'll be there after the function returns. Undefined behavior and such.
Thanks. I switched my strategy, but now I am running into another issue. I have looked online, and I seem to be doing what is validated on different posts. But I get the error message, which says:
[CODE][$ gcc 132.c -o 132
132.c:2:16: error: unknown type name 'month'
void getMonth (month x)
^/CODE]
Here is my implementation
Code:
#include <stdio.h>
void getMonth (month x)
{
}
int main (void)
{
enum month { January = 1, February = 2, March , April, May, June, July, August, September, October, November, December };
enum month aMonth;
int days;
printf ("Enter month number: ");
scanf ("%i", &aMonth);
switch (aMonth) {
case January:
case March:
case May:
case July:
case August:
case October:
case December:
days = 31;
break;
case April:
case June:
case September:
case November:
days = 30;
break;
case February:
days = 28;
break;
default:
printf ("bad month number\n");