How to compile simple command prompt apps in VC++ .NET like in VC+

G

Guest

I have the following simple program:

#include <iostream>
#include <map>
#include <string>
#include <sstream>
#include <fstream>
#include <vector>
using namespace std;

typedef map<string, int> wordmap;

int main(int argc, char* argv[])
{
if (argc != 2)
cout << "Usage: " << argv[0] << " <filename>\n";
else
{
ifstream ifs(argv[1]);
if (! ifs)
{
cout << "The file " << argv[1] << " couldn't be opened.\n";
return 1;
}
string line, word;
vector<wordmap> words;
while (getline(ifs, line))
{
istringstream iss(line);
while (iss >> word)
{
for (wordmap::iterator iter = words.begin(); iter != words.end(); ++iter)
;//if ((*iter).
}
}
}

return 0;
}

How can I compile it with Visual Studio C++ .NET 2003? In Visual Studio C++
6 it was possible, but how do I do it (if possible) in .NET 2003? Just
opening this file will not let me compile it in .NET 2003.... Help!
 
B

BobF

The buildlog from a similar project done in the IDE would be a great start.
Also, open Help>Index and type in 'command'. Tons of good info!
 
C

Carl Daniel [VC++ MVP]

Joachim said:
How can I compile it with Visual Studio C++ .NET 2003? In Visual
Studio C++ 6 it was possible, but how do I do it (if possible) in
.NET 2003? Just opening this file will not let me compile it in .NET
2003.... Help!

To compile in the IDE you need to make a project. File|New|Project|Visual
C++ Projects|Win32|Win32 Console Project.

On the project options page, check the "Empty Project" box to produce a VC++
project with no files. If your file already exists, you can then add it to
the project, or create a new file and paste your code in.

From the command line you can simply compile the standalone file just like
you could with VC6:

cl yourfile.cpp

HTH

-cd
 
B

BobF

The buildlog from a similar project done in the IDE would be a great start.

Also, open Help>Index and type in 'command'. Tons of good info!
 
G

Guest

Thanks Carl,

I have tried this, but then the headers <iostream> etc, are not found.
Isn't the environment variables set automatically for this by VS? I have
found the source file "iostream.cpp", but the header file I cannot find
anywhere. Do you, or someone else, know where I can find it? It is included
in VS .NET 2003, is it?

Regards,
Joachim
 
W

William DePalo [MVP VC++]

Joachim said:
I have tried this,

this being

cl foo.cpp

?

If so, then before you do that run VSVARS32.BAT typically located in

C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools

Regards,
Will
 
A

Arnaud Debaene

Joachim said:
Thanks Carl,

I have tried this, but then the headers <iostream> etc, are not
found. Isn't the environment variables set automatically for this by
VS? I have found the source file "iostream.cpp", but the header file
I cannot find anywhere. Do you, or someone else, know where I can
find it? It is included in VS .NET 2003, is it?

The standard header files should be in <Visual tudio .NET install
directory>\Vc7\include. If they aren't there, something is wrong in your
installation. Do an "Add or Remove Components" and chack that all necessary
parts of VC are really intalled.

Arnaud
MVP - VC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top