how to compile with visual studio 2008

Apr 24, 2009 at 10:20am
Hello there,

I installed visual studio 2008 a few days ago, but still am unable to compile a simple C++ program. Does anyone have an idea of the changes that have occurred to this version of visual C++, or the new libraries that should be included?

I'm always getting this error:

fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory

Thank you
Apr 24, 2009 at 10:47am
That's odd. 2008 should come with the deprecated headers.
Try using iostream (without the .h).
Back in 1999, the old *.h headers were deprecated and replaced with extensionless equivalents. Also, the std namespace was created under which all the C++ standard library types and functions are declared. So now it's std::cout, not cout.
Apr 24, 2009 at 11:40am
If your using 2008 express - That doesn't come with iostream.h. Just do as helios said and it'll work fine.
Apr 24, 2009 at 2:00pm
I also tried the iostream without the ".h", but it didn't work. Could it be because i'm not saving in the original (default) destination?
Apr 24, 2009 at 7:46pm
The line should be:

#include <iostream>

I'm guessing you used quotation marks instead of angle brackets. Quotes are for headers local to your project, brackets are for global headers.
Last edited on Apr 24, 2009 at 7:46pm
Apr 27, 2009 at 6:51am
The problem is solved :

I should have included the following libraries:

#include "stdafx.h"
#include <iostream>
#include <stdio.h>
using namespace std;

the last one permits the usage of the original cout<< instead of the std::cout<<
Apr 27, 2009 at 8:33pm
Actually, the statement "using namespace" is for declaring the contents of a namespace as part of the global scope, so that you don't have to call that specific namespace before every object contained in it.

For example, if I had a namespace titled "threading," which contained the class "Semaphore," the class would be instanced using:

threading::Semaphore semaphore;

Whereas the declaration of the threading namespace is unnecessary if I declare it as part of the global scope beforehand:

1
2
3
4
using namespace Semaphore;

//The inclusion of the scope in which the object is contained is now unnecessary
Semaphore semaphore;


---

the last one permits the usage of the original cout<< instead of the std::cout<<


In reality, both of these are the exact same objects, they're just called in different ways.

Also, "cout" and "<<" are two separate things. "Cout" is an object which prints output to the console using a stream. The operator "<<" is used to differentiate objects in the stream.

For example:

cout << "This is a string object " << /*This is an integer object*/ 9 << /*This is an object which declares a newline character in the stream*/ endl;
Last edited on Apr 27, 2009 at 8:38pm
Topic archived. No new replies allowed.