Solved

VC++ .NET

Posted on 2004-09-22
8
354 Views
Last Modified: 2010-04-01
I just installed VC++ .NET (7.1).  When trying to write a test console app, it seems that the syntax for everything may be different....  anyone else had this experience?
0
Comment
Question by:fattumsdad
  • 3
  • 3
  • 2
8 Comments
 
LVL 16

Expert Comment

by:nonubik
ID: 12125332
int _tmain(int argc, _TCHAR* argv[])
{
      return 0;
}

The _tmain function is a macro for either wmain or main (UNICODE char set used or not).
So is the TCHAR, a macro for either wchar_t or char.
0
 
LVL 16

Expert Comment

by:nonubik
ID: 12125352
So if you do not use UNICODE, the code will look like this (to the compiler) :

int main(int argc, char* argv[])
{
      return 0;
}

If you use UNICODE:

int wmain(int argc, wchar_t* argv[])
{
      return 0;
}

..if that's what you mean by "it seems that the syntax for everything may be different"
0
 
LVL 86

Expert Comment

by:jkr
ID: 12125390
You need to use an _unmanaged_ project, since otherwise, everything will be *very* different. E.g. a simple "Hello World!" mutates to

#using <mscorlib.dll>

// Allow easy reference to the System namespace classes.
using namespace System;

// The global function, main, is the application's entry point.
void main() {
   // Write text to the console.
   Console::WriteLine(S"Hello World using Managed Extensions for C++!");
}

See e.g. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptutorials/html/hello_world_in_managed_extensions_for_c__.asp ("Hello World in Managed Extensions for C++")
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 1

Author Comment

by:fattumsdad
ID: 12125435
So if I use an unmanaged project, I should be able to continue with the syntax that I'm used to?  

#include <iostream>

using namespace std (or would it have to be "system");

int main()
{
   var whatever;

   cout << "xxxxxXx
   cin >> var

   return 0;
}
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 12125487
>> So if I use an unmanaged project, I should be able to continue with the syntax that I'm used to?

Yup, absolutely, a simple

#include <iostream>

using namespace std;

int main()
{
  float fPrice;

  cout << "Hello World, what's your price?" << endl;
  cin >> fPrice;

  return 0;
}

will do.
0
 
LVL 1

Author Comment

by:fattumsdad
ID: 12125515
Excellent!  I appreciate the help.  Another question...  different subject...  how familiar are you with C# and J#?
0
 
LVL 86

Expert Comment

by:jkr
ID: 12125549
>>how familiar are you with C# and J#?

Zero. Nada. Niente. I can spell their names, though :o)
0
 
LVL 1

Author Comment

by:fattumsdad
ID: 12125562
LOL that makes two of us...  I want to learn C# but I hear it's basically Java with a different name....  no idea what this J# is.  I guess I should just stick with C++ LOL I'm years away from coming close to mastering that!
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question