cout << "\nEnter the name of the file you want to create: ";
cin >> FileName;
ofstream Student(FileName, ios::out);
Student << RegNo << " " << AssignmentMark;
return 0;
}
There're three things I'm not sure about your variables.
Why are you allocating arrays in each case? In the case of an int, you don't need an array because int stores numbers ranging from about -2 billion to +2 billion, not single digits.
The same goes for float. It doesn't store individual digits, it stores entire numbers, although I don't remember the range. For something like grades, though, it'll work fine, so... :)
Also, in place of your char[] you can use a string after #include/*ing*/ <string> . Not only is it much safer, but you don't have to specify how long your string will be.