By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,473 Members | 3,292 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,473 IT Pros & Developers. It's quick & easy.

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

P: n/a
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!
Nov 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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!
"Joachim" <Jo*****@discussions.microsoft.com> wrote in message
news:8C**********************************@microsof t.com...
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!

Nov 17 '05 #2

P: n/a
Joachim wrote:
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
Nov 17 '05 #3

P: n/a
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!

"Joachim" <Jo*****@discussions.microsoft.com> wrote in message
news:8C**********************************@microsof t.com...
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!

Nov 17 '05 #4

P: n/a
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

"Carl Daniel [VC++ MVP]" wrote:
Joachim wrote:
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

Nov 17 '05 #5

P: n/a
"Joachim" <Jo*****@discussions.microsoft.com> wrote in message
news:BF**********************************@microsof t.com...
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
Nov 17 '05 #6

P: n/a
Joachim wrote:
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
Nov 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.