![]() |
|
#1
|
|||
|
|||
Multiply 6X6 Matrices using "infile" (DAT file)Hey guys,
I'm stuck on a Matrix assigment at the moment. The assignment asks us to multiply 2 6x6 matrices together and show the result. Our inputs are supposed to come form a .DAT file.. Can you guys show me how I would incorporate the "infile" into my current project? My current currently asks for someone to input numbers... but my instructor wants us to get input from the .DAT files.. Below is my current code. CPP / C++ / C Code:
|
|
#2
|
|||
|
|||
Re: Multiply 6X6 Matrices using "infile" (DAT file)Quote:
1. Declare an ifstream and give it the name of your file. 2. Make sure it was opened correctly. Tell the user what happened. (Did it open it or not?) 3. Use the overloaded operator >> to read the values. 4. Each and every time, make sure that it was able to read. If it was not able to read everything, inform the user. For now, just bail out if it sees an error condition. For example: CPP / C++ / C Code:
Now, try something like the following as the file "test.dat": Code:
Output: Code:
Now go back to test.dat and put in an error. Maybe put a comma instead of a period in 4.00001: Code:
Output: Code:
Now, go back and rename your file "test.dat" to something else (so there is no file named "test.dat"). Output: Code:
Regards, Dave |
Recent GIDBlog
Toyota - 2008 July Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Airport Log program using 3D linked List : problem reading from file | batrsau | C Programming Language | 11 | 29-Feb-2008 07:44 |
| After execution - Error cannot locate /Skin File? | WSCH | CPP / C++ Forum | 1 | 05-Mar-2005 20:03 |
| Yet another CD burner problem: Lite-On LSC-24082K | Erwin | Computer Hardware Forum | 1 | 22-May-2004 11:28 |
| CD Buring Failed | skanth2000 | Computer Hardware Forum | 1 | 15-Nov-2003 03:52 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The