Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 7th, 2005, 12:56 PM   #1
splitterdevildoll
Newbie
 
Join Date: Aug 2005
Posts: 12
Rep Power: 0 splitterdevildoll is on a distinguished road
Error messages - time program

I am trying to compile a program, but an error message shows up saying that it cannot open the iostream file. Is there anything wrong with the compiler or my code?

I'd appreciate any feedback.

This is my code.
---------------
/*Get the current time.
* Ask the user to type, "The quick brown fox jumped over the lazy dog."
* Read a line of input.
* Get the current time again.
* Use the number of words in the sentence and the difference between the two times to calculate the words per minute they typed.*/

#include <iostream>
using namespace std;

#include "ccc_time.cpp"

int main()
{
Time now = time();
cout << "Please type: The quick brown fox jumped over the lazy dog\n";
string statement;
cin >> statement;
Time statement_read =time();
Time difference = statement_read.seconds_from(now);
difference.get_minutes();
int length_of_statement = statement.length();
double words_per_minute = length_of_statement/difference;
cout << words_per_minute <<"\n";
return 0;
}
splitterdevildoll is offline   Reply With Quote
Old Aug 7th, 2005, 1:14 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
If the preprocessor is bombing out at the first #include statement, the quality of your code is totally immaterial. You don't mention your compiler or your system and you don't reproduce the error message. One has to guess at things, which isn't the best way to work. Try to remember, in future, that information is key. That said, make sure the path to your include files is known to the compiler, whether via IDE settings or command line material or environment path specifications. Please read the forum's FAQ/Rules and use code tags in future. These are HTML pages; as such they eat whitespace.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Aug 7th, 2005, 3:00 PM   #3
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
I think I had that C++ book - it came with a CD with those header files and libraries if i'm not mistaken, and provided a URL at which you can download them if you lost the CD.
Cerulean is offline   Reply With Quote
Old Aug 7th, 2005, 8:15 PM   #4
prolog
Programmer
 
Join Date: Jul 2005
Location: Germany
Posts: 69
Rep Power: 4 prolog is on a distinguished road
Hi,

is that really from a book ? I'd recommend throwing this book right into the next corner. I consider including cpp-files really bad style and error prone. Anything else related to you post is allready said by DaWei.
__________________
-= C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do succeed, you will blow away your whole leg. =- Bjarne Stroustrup
prolog is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:18 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC