Reply embedded...

> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of
> [EMAIL PROTECTED]
> Sent: Thursday, August 10, 2006 2:11 PM
> To: [email protected]
> Subject: [c-prog] Visual C++ 2005 Express: Oddities?
> 
> Hi all,
> 
> I've decided to take some of my ancient C code and move into the C++
> world. Per the  recommendations here, I am using VC++ express.
> 
> I have found some odd behavior and was hoping someone here could explain
> it.
> 
> Below is my program. I made a few changes which affected the output
> described below the source.
> 
> // CppTest3.cpp : Defines the entry point for the console application.
> //
> 
> #include "stdafx.h"
> #include <iostream>
> #include "stdio.h"
> 
> using namespace std;
> 
> int main(int argc, _TCHAR* argv[])
> {
>      cout << "Hello World From About" << endl;
> 
>      cout << "The command you typed was \"" << (char *)argv[0] << "\""
> << endl;
> 
>      if (argc == 1)
>      {
>          cout << "You have not supplied any command line arguments." <<
> endl;
>      }
>      else if (argc == 2)
>      {
>          cout << "You have supplied " << argc - 1 << " command line
> argument." << endl;
>          cout << "It is \"" << (char *)argv[1] << "\""<< endl;
>      }
>      else
>      {
>          cout << "You have supplied " << argc - 1 << " command line
> arguments.";
>          cout << " They are: " << endl;
>          for (int loopctr = 1; loopctr < argc; loopctr++)
>          {
>              cout << "(" << loopctr << "): \"" << (char *)argv[loopctr]
> << "\"" << endl;
>          }
>      }
> 
>      return 0;
> }
> 
> When I start a new project I get the entry point _tmain() rather than
> main(). This causes the argv[] values to be printed as a single char
> rather than a string of chars, like so:

_tmain() is called in the Windows term: "generic text mapping function".
Will resolaved to wmain() if _UNICODE is defined, and to main() otherwise.

IIRC, VC++2005 defaults to UNICODE built.  argv[] stored command line
arguments in UNICODE.  

To change this setting:
- In Solution Explorer, right click on Project, Select "Properties".
- Expand "Configuration Properties", select "General".
- On the right pane, expand "Project Defaults", Select "Character Set".
- Select "Not Set" or "Use Multi-Byte Character Set".

Or kept it as UNICODE buy change the output from std::cout to std::wcout
when outputting argv[].  For example:

    cout << "The command you typed was \"";
    wcout << argv[0];
    cout << "\"" << endl;

HTH
Shyan




To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/c-prog/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to