Trying to save to file using switch case

Mar 6, 2009 at 6:37pm
I'm trying to get someone to pick from a list of classes, and have that class saved to a file, but I can't get it to work with more then one case. I keep getting error c3867. Here's the part that I know is giving me the error:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
switch (class1)
	{
	case 1: {ofstream myfile;
			myfile.open("Registration.txt");
			myfile <<"EML 1234\nBeginning Principles of Engineering \n3 credits\nMonday Wednesday Friday\n12:00PM to 12:50 PM";
			myfile.close;
			break;}
	case 2: {ofstream myfile;
			myfile.open("Registration.txt");
			myfile <<"EML 1234\nBeginning Principles of Engineering \n3 credits\nMonday Wednesday Friday\n12:00PM to 12:50 PM";
			myfile.close;
			break;}
	case 3:{ofstream myfile;
			myfile.open("Registration.txt");
			myfile <<"EML 1333\nIntro to Programming\n3 credits\nTuesday Thursday\n9:00AM to 10:15AM\n";
			myfile.close;
			break;}
	case 4: {ofstream myfile;
			myfile.open("Registration.txt");
			myfile <<"EML 1525\nStructural Design for Engineers\n3 credits\nMonday Wednesday Friday\n2:00PM to 2:50PM \n";
			myfile.close;
			break;}
	case 5: {ofstream myfile;
			myfile.open("Registration.txt");
			myfile <<"EML 1303\nEngineering Theory\n3 credits\nTuesday Thursday \n12:00PM to 1:15PM";
			myfile.close;
			break;}
	}
Mar 6, 2009 at 6:48pm
I keep getting error c3867


It would help tremendously if you told us what that error was. Most people don't memorize error numbers, and error numbers can vary depending on your platform/compiler.

Also telling us specifically what line the error is occuring on would help.

Anyway the thing that jumps out at me is that you're doing myfile.close instead of myfile.close();. Remember you need to have the parenthesis to call a function.
Mar 6, 2009 at 6:48pm
Error 3867:
'func': function call missing argument list;

myfile.close should be myfile.close()
Mar 6, 2009 at 7:38pm
YES! Thank you so much. I missed that entirely. Thanks a lot!
Topic archived. No new replies allowed.