// Program 2.25: Distance an object travels in miles
// and time it takes to travel that distance
// Author: Eric Martin
// Date: 9/30/2004
 #include <iostream.h>
using namespace std;
   int main()
   {
      int distanceInMiles;
      int speedInMPH;
      int timeInMinutes;

      cout << "Computes time to travel given distance and speed" << endl;

      cout << "Enter distance in miles: ";
      cin  >> distanceInMiles;
      cout << "Enter speed in miles per hour: ";
      cin  >> speedInMPH;

      timeInMinutes = distanceInMiles * 60 / speedInMPH;

      cout << "It takes " << timeInMinutes << " minutes to travel " 
           << distanceInMiles << " miles at " 
           << speedInMPH << " miles per hour" << endl;

      return 0;
   }

When I build the program in Visual Studio..it comes up with fatal error: unable to locate .h file or somethin...wtf? :(

Dani AI

Generated

Short clarification and practical checklist on the “header not found” symptom. and correctly noted the difference between old-style headers and the standard headers; ’s namespace tip is also relevant for linker/identifier errors. However, missing-header errors often come from build-configuration issues rather than the single include line. The most useful checks are about how the file is recognized and how the IDE finds the standard library.

Common checks and quick fixes:

  • Confirm the source file is treated as C++ (use a .cpp extension or set Project → Properties → C/C++ → Advanced → Compile As to C++).
  • Precompiled-header templates are common in MSVC: either include the project’s precompiled header (typically named stdafx.h) as the first include or disable precompiled headers under Project → Properties → C/C++ → Precompiled Headers.
  • Verify the compiler’s include paths: ensure the IDE’s VC++/compiler Include Directories point at the standard-library headers installed with the compiler (or check the INCLUDE environment variable when using the command-line compiler).
  • If using Dev-C++/MinGW, confirm the compiler is g++ (C++ mode) and the toolchain is complete; an incomplete install can omit headers.
  • Reinstall or repair the IDE/toolchain if standard headers are actually missing from the install folder.

Why these matter: switching from nonstandard headers to the standard ones (the change suggested) is the right move, but if the file is compiled as C, or the project expects a precompiled header, or the include paths are wrong, the compiler will produce a cascade of errors even after using the correct header. A focused verification of file extension, project C/C++ settings, precompiled-header usage, and include directories usually isolates the real cause.

Recommended Answers

All 6 Replies

i have the same prob with dev c++ i couldn't figure out how to fix it. Try just doing a reinstall. This is such annoying problem too because most programs are made with iostream header file.

Try #include<iostream> instead of iostream.h
Not sure if that will definitely work, but supposedly it's the new standard.

I agree with cscgal,

I have stated this time and time again:

The difference between iostream and iostream.h (summary)
You should avoid using the *.h version as much as possible, because some implementations have bugs in their *.h version. Moreover, some of them support non-standard code that is not portable, and fail to support some of the standard code of the STL.

Furthermore, the *.h version puts everything in the global namespace. The extension-less version is more stable and it's more portable. It also places everything in the std namespace.

iostream.h is an old style method of including std C++ headers, and in opposite to iostream you don't have to declare that you're using the std namespace.

As cscgal stated, #include <iostream> without the *.h may solve the issue.


- Stack Overflow

that solved it for me thanks dani. There is no more errors when i compile it using because of that i still have some bugs to tweak with dev c++ but im not sure if i downloaded the beta or not. Sorry about tagging your problem.

i tried iostream without .h...and i get even more fatal errors...i guess i should reload?

>i tried iostream without .h...and i get even more fatal errors...i guess i should reload?
No, you should consider namespaces. An easy fix is to say using namespace std; after you include all of your headers. This isn't the best fix, but it is quick and usually works if you don't have other errors.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.