473,771 Members | 2,347 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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::itera tor 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
6 1430
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*****@discus sions.microsoft .com> wrote in message
news:8C******** *************** ***********@mic rosoft.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::itera tor 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
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|Projec t|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
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*****@discus sions.microsoft .com> wrote in message
news:8C******** *************** ***********@mic rosoft.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::itera tor 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
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.c pp", 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|Projec t|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
"Joachim" <Jo*****@discus sions.microsoft .com> wrote in message
news:BF******** *************** ***********@mic rosoft.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\To ols

Regards,
Will
Nov 17 '05 #6
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.c pp", 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4572
by: Shuo Xiang | last post by:
Greetings: After using it at my place of work, I have found that Visual Studio is indeed very convenient -- I can open all sorts of documents and even browse the net without ever leaving the IDE. But I would just like to know if I could push it a little further: could I have the command prompt (cmd) show up as one of the files being displayed in Visual Studio under its own tab within my current project, or do I HAVE to open up a...
9
1749
by: Jaime | last post by:
I am using Microsoft Visual C++ and i have some projects configuration. (Configuration A, Configuration B, ..., Configuration N) I need to execute some system operation call such as copy, delete, etc before each one project configuration compilation. How do i do it? Regards,
13
1960
by: Nick Z. | last post by:
Whenever I try to compile a VC++ program using VS .NET 2003 I get an error saying mspdb71.dll not found. How can I fix this error? PS. I ran vsvars32.bat and it did not change a thing. Thanks, Nick Z.
3
3096
by: | last post by:
I am trying to compile a simple c# class in Web Matrix called howdy.cs: // Program start class public class HowdyPartner { // Main begins program execution public static void Main() { // Write to console
4
1993
by: Seok Bee | last post by:
Dear Experts, I've completed my console application and now wants to compile the application and an executable file to be run at another location. However, I've tried compiling that program in the command prompt with the following command : vbc Module1.vb /out:OEAutomation.exe /t:exe I received a lot of error messages.
3
2278
by: Steven | last post by:
I am using VC++ 6.0 to build a windows based application, however, my application allows user to input command arguments in the dos prompt windows. I want to have a warning message for user if they have input the wrong arguments. How can I write text to the dos prompt windows if user input the wrong arguments? Thanks in advance. Steven.
3
6498
by: =?Utf-8?B?S3VlaXNoaW9uZyBUdQ==?= | last post by:
I have a .NET VC++ program, I want to execute some dos command from the program, e.g. copy some file, and etc. How do I do that?
3
4579
by: Tom Baxter | last post by:
I just set up VS 2008 B2 and did a simple command line compile from the VS command prompt. I received this warning: warning CS1668: Invalid search path 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\lib' specified in 'LIB environment variable' -- 'The system cannot find the path specified. ' When I checked, sure enough, the "lib" directory is not present'. Perhaps I
14
1770
by: Anna Smidt | last post by:
After having programmed since 8 years only VB6 I want to learn C++.NET now. It's amazing that everything has to be prepared first. For example I want to build the DirectShow baseclass, but the only files I found in the PSDK\Samples\Multimedia\DirectShow\BaseClasses are ..cpp ..h makefile I would like to ask how I should compile them because I was thinking
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10102
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9910
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.