so i'm studying beginner C but i've got mad problems with this switch function in xcode:
New Project > Command Line Utility > Standard Tool
the errors i'm receiving state "Case Label Not Within Switch Statement", but they totally are, aren't they?!
i also get that weird warning "Return Type Defaults To Int" if i write "main()" instead of "int main()"...
New Project > Command Line Utility > Standard Tool
Code:
#include <stdio.h>
main ()
{
int number;
printf("Make a choice (1 / 2 / 3): ");
do
{
scanf("%d", &number);
switch (number);
{
case (1) : printf("You chose #1\n");
break;
case (2) : printf("You chose #2\n");
break;
case (3) : printf("You chose #3\n");
break;
default : printf("Invalid Choice (\"%d\"). Please Select Again.\n", number);
}
}
while ((number < 1) || (number > 3));
return 0;
}
the errors i'm receiving state "Case Label Not Within Switch Statement", but they totally are, aren't they?!
i also get that weird warning "Return Type Defaults To Int" if i write "main()" instead of "int main()"...