switch statement problems: beginner in C
hey guys, first time poster so let me know if I violate any basic rules, don't want to step on any toes. I'm taking a basic C programming class, and I'm having trouble with the following switch statement.
if the problem isn't in here, it's got to be in the rest of my program. I run a printf to make sure my r is correct in output and it feeds me -12093. I was just wondering if I was making some stupid mistake in my syntax here. thanks.
Code:
void daysinmonth(int p, int r)
{
switch(p)
{
case 1:
r=31;
break;
case 2:
r=28;
break;
case 3:
r=31;
break;
case 4:
r=30;
break;
case 5:
r=31;
break;
case 6:
r=30;
break;
case 7:
r=31;
break;
case 8:
r=31;
break;
case 9:
r=30;
break;
case 10:
r=31;
break;
case 11:
r=30;
break;
case 12:
r=31;
break;
}
}