outfile in VC++ 2005 Express Edition

I am using VC++ 2005 Express Edition. I am trying to write the values of three textboxes and a date time picker to a file.
This is the problem area of the file:

1
2
3
4
5
6
7
8
9
10
11
12
#pragma endregion
	private: System::Void submit_Click(System::Object^  sender, System::EventArgs^  e) {
		ofstream outfile("xxx.dat (I omitted the directory)", ios::app);
		outfile << "Employee: " << name->Text << endl; 
		outfile << "Time In: " << timein->Text << endl; 
		outfile << "Time Out: " << timeout->Text << endl;
		outfile << "Date: " << date_time->Value << endl;
		outfile << endl;
		outfile.close();
					 }
};
}


I get the following error message:
1
2
3
4
Error	1	error C2088: '<<' : illegal for class	191
Error	2	error C2088: '<<' : illegal for class	192
Error	3	error C2088: '<<' : illegal for class	193
Error	4	error C2088: '<<' : illegal for class	194
Last edited on
closed account (S6k9GNh0)
I'll help you out when you figure out how to use the CODE tags
code tag?
He means put [code][/code] tags around your code so

//shows up like this

Anyway...I can't actually see anything that would cause a problem with that...That is quite strange.
Thanks.
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
#pragma endregion
private: System::Void submit_Click(System::Object^ sender, System::EventArgs^ e) {
ofstream outfile("xxx.dat (I omitted the directory)", ios::app);
outfile << "Employee: " << name->Text << endl; /*employees name, name->text is the value of a text box.*/ 
outfile << "Time In: " << timein->Text << endl; /*time in of the employee, timein->text is the value of a text box.*/ 
outfile << "Time Out: " << timeout->Text << endl; /*time out of the employee, timeout->text is the value of a text box.*/
outfile << "Date: " << date_time->Value << endl; /*date of the employee, date_time->Value is the value of a datetimepicker. */ 
outfile << endl;
outfile.close();
}
};
}


I get the following error message:
1
2
3
4
Error 1 error C2088: '<<' : illegal for class 191
Error 2 error C2088: '<<' : illegal for class 192
Error 3 error C2088: '<<' : illegal for class 193
Error 4 error C2088: '<<' : illegal for class 194


Well there it is with comments.
Last edited on
Is there anyway for me to convert those values (e.g. timeout->Text) to strings? That would make them so much easier to manipulate, i think.
i figured out how to convert the values to strings but I still get the same error message.
The new code (relevant to the problem):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#pragma endregion
	
private: System::Void submit_Click(System::Object^  sender, System::EventArgs^  e) {
		
     System::String^ Name = name->Text; //convert name to string  
     System::String^ in = timein->Text; //convert timein to string		
     System::String^ out = timeout->Text; //convert timeout to string	
     System::String^ Date = date->Text; //convert date to string (I changed the date time picker to a text box)		
     ofstream outfile("-------------/Desktop/Calendar.dat", ios::app); //initiate outfile, append to end of specified file		
     outfile << "Employee: " << Name << endl; //export Name to calendar.dat...
     outfile << "Time In: " << in << endl; //export in to calendar.dat...
     outfile << "Time Out: " << out << endl; //export out to calendar.dat...
     outfile << "Date: " << date << endl; //export date to calendar.dat...
     outfile << endl; //add an extra line between employees
		
outfile.close();
}
Last edited on
Topic archived. No new replies allowed.