Announcements | Last Post | |
---|---|---|
![]() |
SoC Curricula | 09/30/2017 01:08PM |
![]() |
Demarcation or scoping of examinations and assessment | 02/13/2017 07:59AM |
![]() |
School of Computing Short Learning Programmes | 11/24/2014 08:37AM |
![]() |
Unisa contact information | 07/28/2011 01:28PM |
I/O streams help...What's wrong with this code May 25, 2008 02:47PM |
Registered: 12 years ago Posts: 62 Rating: 0 |
Re: I/O streams help...What's wrong with this code May 25, 2008 03:54PM |
Registered: 12 years ago Posts: 62 Rating: 0 |
![]() May 25, 2008 07:11PM |
Registered: 11 years ago Posts: 1,268 Rating: 0 |
ins >> next; // PROBLEM while (ins >> next)
ins >> next, you only need the while
May 26, 2008 05:46PM |
Registered: 14 years ago Posts: 1,424 Rating: 0 |
do { ins >> next; sum = sum + next; } while (!ins.eof()); ins.close();
while (!ins.eof()) { ins >> next; sum = sum + next; } ins.close();
if (ins.fail( )) { cout << "Input file opening failed.\n"; return 1; }is the better alternative.
![]() May 26, 2008 09:29PM |
Registered: 11 years ago Posts: 1,268 Rating: 0 |
while (messy_file >> next)
Re: I/O streams help...What's wrong with this code May 27, 2008 09:03AM |
Registered: 12 years ago Posts: 62 Rating: 0 |
May 27, 2008 01:36PM |
Registered: 14 years ago Posts: 1,424 Rating: 0 |
Re: I/O streams help...What's wrong with this code May 27, 2008 05:24PM |
Registered: 11 years ago Posts: 41 Rating: 0 |
May 27, 2008 10:20PM |
Registered: 14 years ago Posts: 1,424 Rating: 0 |
Re: I/O streams help...What's wrong with this code May 28, 2008 09:44AM |
Registered: 12 years ago Posts: 2,075 Rating: 0 |
void error(string message) { cout<<"error: "<<message<<endl; system("pause" exit(-1); }
Re: I/O streams help...What's wrong with this code May 28, 2008 11:03AM |
Registered: 11 years ago Posts: 41 Rating: 0 |
Re: I/O streams help...What's wrong with this code May 28, 2008 11:14AM |
Registered: 12 years ago Posts: 2,075 Rating: 0 |
May 28, 2008 01:56PM |
Registered: 14 years ago Posts: 1,424 Rating: 0 |
int main() { // some code try { // some code that causes some kind of fault in the program if (errorCondition) { throw "errorCondition is true"; } } catch (string errorMessage) { cout << "error: " << errorMessage << endl; return -1; } return 0; // end the program, telling the OS that there were no errors }
Re: I/O streams help...What's wrong with this code May 28, 2008 03:11PM |
Registered: 11 years ago Posts: 53 Rating: 0 |
Re: I/O streams help...What's wrong with this code May 30, 2008 12:34AM |
Registered: 11 years ago Posts: 41 Rating: 0 |
May 30, 2008 10:31AM |
Registered: 12 years ago Posts: 475 Rating: 0 |
May 30, 2008 11:02AM |
Registered: 11 years ago Posts: 1,268 Rating: 0 |
Re: I/O streams help...What's wrong with this code May 30, 2008 11:23AM |
Registered: 11 years ago Posts: 41 Rating: 0 |
May 30, 2008 11:09PM |
Registered: 12 years ago Posts: 475 Rating: 0 |