writing into a text file with void function?

Why can I not write like this? Error keep on appearing on line 9.

1 void student::writeLongRecord()
2 ofstream("student_data.txt");
3 fstream stu;
4 int i=0;
5
6 student.open("student_data.txt",ios::in|ios::out);
7 do{
8 i=i+1;
9 stu << i << " " << student::getRegNo() << " " << fixed << setprecision(1) << student::getAssignmentMark << endl;
10 }
You appear to be missing { } on your function.
You are also not opening your fstreams correctly, go re-read the documentation or your tutorial on them.

Error messages would help though.
thanks for pointing that out :) I have solve my problem.
Topic archived. No new replies allowed.