Tuesday, July 14, 2009

File handling in C?

hi guys and gals. i've gotta submit a project. i hav to handle student details such as name, roll number,5 marks, avg,result and rank. i need to save it in a file using C. cud u plz help me gettin the codes. plz.

File handling in C?
Unless you're working with a database system (and you probably aren't), the file management is the least of your worries.





First, develop a program that handles the records in an array (or better, an STL vector or a linked list) in memory. That's where you're going to have to add records, delete records, sort records, etc. It's easier to manage it here than in a file.





Second, write code that goes through your array/list and writes each record to a file. You'll then write the opposite of that which builds a list from the file. These you'll call when your program quits and when it starts. If you want to get fancy, you might save more frequently than this in case of crashes, either on a timer or before and after sorting or other operations.





Now to the crux of your question, how to do this. That's going to depend a lot on what API you're using. In windows you'd use CreateFile and WriteFile. Using standard C or C++ with streams will give you other options.





I've added a link here to an article that goes over some of the standard C options for reading and writing files.





http://www.exforsys.com/content/view/207...
Reply:The file save fuction is differ C# then GML.





To write GML go to http://www.gamemaker.nl/download.html

cabbage

No comments:

Post a Comment