![]() |
| ||
| Help Reading Info in Text File Into an Array Hi, I'm working an a project that must take a text file (provided to us, in.txt) that has the scores of students from different sections on different labs. You can view the assignment page at: http://www.cs.wmich.edu/~nelson/CS11...ab06/index.htm. The problem I'm having is that I can't think of how to make a function that will read the file and put it into an array (no function in this program is supposed to be more than 24 lines so there's no way it can go into the main funciton, I was planning on making a readFile function to do this work). Can you pass a file to a funciton as a paramater (I got an error, I didn't think it was possible, just wanted to try)? Should I read the file in main and somehow pass it to the function in some way? I'm also quite lost as far as I should go about getting the data from the text file stored correctly into the array. This is an example of how the info in the data file is stored: The input file: Name: “in.txt� you must use the name in.txt First line 2 integers: The number of sections in the class <= 10 The number of lab assignments in the class, NumLabs <= 10 For Each Section First Line, 1 Integer: N The number of students in the section <= 50 For each Student Student Id L1 L2 … LNumLabs Student Id: 4 digit integer Labs scores: Integers 0 to 100 Example: A small class with 3 sections and 4 labs. The first section has 4 students, the second 5 and the third 4 3 4I tried setting up some for loops in a test program to read info from the input file into an array (not included into my actual program because as stated above I can't figure out how to implement it into my actual program) but go no where. Could someone help me figure out how to go about this? I would be very grateful to any help. thanks again for everything, -Scott  |
| ||
| Re: Help Reading Info in Text File Into an Array Hi, I found the following article when looking for help writing and reading parameter storage files as CSV files for a current application. Although the example is based on .NET code you should be able to get some ideas on how you can write a similar function yourself. http://www.developer.com/net/cplus/article.php/3406181 |
| ||
| Re: Help Reading Info in Text File Into an Array Quote:
thanks yet again, -Scott |
| All times are GMT -4. The time now is 4:25 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC