Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VC++ .NET

Posted on 2004-09-22
8
Medium Priority
?
361 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

972 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