![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Aug 2005
Posts: 12
Rep Power: 0
![]() |
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; } |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#3 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
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.
|
|
|
|
|
|
#4 |
|
Programmer
Join Date: Jul 2005
Location: Germany
Posts: 69
Rep Power: 4
![]() |
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 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|