I'm getting this error for my CASE 5/6/7/8.
I'm sure it's something obvious as it was working before I started adding addition function calls to CASE 4.
What does the error mean?
error: case label in scope of identifier with variably modified type not containing enclosing switch statement
switch(menu_selection())
{
case 0 : i = find_empty_record(data_record); //New record
if (i!=-99)
{
printf("\n\nRecord #%d found to be empty...\n\n",i);
data_entry(&data_record[i],i,&array_flag);
}
break;
case 1 : //Edit
i=record_selection(array_flag);
data_entry(&data_record[i],i,&array_flag);
break;
case 2 : display_single(data_record,array_flag); //Display single record
break;
case 3 : //Display all records
for (i=0;i<30;i++)
{
print_2_screen(&data_record[i],i,array_flag);
}
break;
case 4 : rec_cnt = get_text_file_size(import_file_name); //Import Text File
student_record data_record[rec_cnt];
import_text_file(data_record,import_file_name,array_flag,rec_cnt);
break;
case 5 : // Import Binary File
break;
case 6 :
export_text(data_record,rec_cnt,array_flag);// Save to Text File
break;
case 7 : // Save to Binary File
break;
default :
break;
}
}
return 0;
student_record data_record[rec_cnt];
You can't declare stuff inside a switch.
Do it in a block:
case 4:
{
student_record data_record[rec_cnt];
/* ... */
}
In case 4 you have an array declaration: student_record data_record[rec_cnt];
Create an extra block:
case 4:
{
rec_cnt = get_text_file_size(import_file_name); //Import Text File
student_record data_record[rec_cnt];
import_text_file(data_record,import_file_name,array_flag,rec_cnt);
}
break;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With