This topic is now archived and is closed to further replies.



Recommended Posts

sevak    100
I have to complete this exercise in the book im reading but for some reason the code I use doesn''t work. Exercise:A serial transmission line can transmit 960 characters a second. Write a program that will caculate how long it will take to send a file, given the file''s size. Try it on a 400MB(419,430,400 byte) file. Use appropriate units. (A 400MB file takes days) Here is my code #include <iostream> #include <stdlib.h> int main() { double bytes = 0; double hours = 0; cout << "Enter number of Bytes: "; cin >> bytes; hours = bytes/57600; cout << "It will take about " << hours << " hours" <

Share this post

Link to post
Share on other sites
Penance    190
Right, you either have to say where the cout and cin methods are coming from explicitely (std::cout, std::cin) or you have to tell the compiler that you''re using the std namespace:

using namespace std;

Share this post

Link to post
Share on other sites
Lektrix    106
Original post by Village Specialton
You forgot a < when writing system("PAUSE");

Scott Simontis
If it wasn't for C, we'd be using BASI, PASAL and OBOL

The break in the code is merely as a result of the forum interpreting the angle bracket as part of an HTML tag. If you click on the 'Edit' or 'Quote' button you can view the actual post body.

I assume from your post that you meant that the OP should be using system() like so:

std::cout << "..." << system("PAUSE");

Although this is valid (it does not cause a compile-time error), it will not work as you most likely desire it to. system() returns an int, representing the type of success or failure of the invocation. Using it as so will pass the integer returned by system() to std::ostream's overloaded left-shift operator method, that is you will be printing this value to the standard output. This is probably not what you intended to do, so you would do something along the lines of this:

std::cout << "..." << std::endl;

[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || MSVC++ Library Fixes || BarrysWorld || E-Mail Me ]

[edited by - Lektrix on August 9, 2003 2:10:23 PM]

Share this post

Link to post
Share on other sites