About Dates and Switches

I am stuck with the first project in C about dates and switches. The code runs this way:
int main(void) {
int month, day, year;
// Standard date form
printf(“Enter date (mm/dd/yyyy): “);
// Split the user input into 3 variables for the date
// Don’t worry about the scanf() below, you’ll learn more about these later!
scanf(”%d /%d /%d”, &month, &day, &year);

// Print the month
switch(month) {
case 1:
printf(“January\n”);
break;
case 2:
printf(“February\n”);
break;
case 3:
printf(“March\n”);
break;
case 4:
printf(“April\n”);
break;
case 5:
printf(“May\n”);
break;
case 6:
printf(“June\n”);
break; // and so on until case 12 for January…
The compiler displays this error message:
$ gcc date.c
date.c: In function ‘main’:
date.c:60:1: error: expected declaration or statement at end of input
}
^
I’m stuck on this because I could not figure out the error message and therefore could not proceed with the next task. I hope somebody can help me with this. Thank you very much…

Paste all of your code but with proper formatting. Otherwise, it is difficult to read code and spot any potential issues. There is probably a “Copy to Clipboard” button at the bottom of the exercise/project. Click on it to copy all your code.

To preserve code formatting in forum posts, see: How do I format code in my posts?

Thanks a lot, mtrtmk and java9731188620 for the replies, I was able to “unstuck” myself :slight_smile: a closing } was missing…

1 Like