Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8650461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:49:42+00:00 2026-06-12T13:49:42+00:00

I am using Visual C++ 2010, and the code is: #include stdafx.h #include <stdio.h>

  • 0

I am using Visual C++ 2010, and the code is:

#include "stdafx.h"
#include <stdio.h> 

int _tmain(int argc, _TCHAR* argv[]) { 
    printf("step 0: %s\n", argv[0]);
    int d;
    scanf("%d",&d);
    return 0;
}

When I choose _UNICODE, the output is “D”,
and when I choose _MBCS, it works well and the output is “D:\VCTest\c1006.exe”

Why is it wrong in _UNICODE?
How can I use the same code for both _UNICODE and _MBCS ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:49:44+00:00Added an answer on June 12, 2026 at 1:49 pm

    When compiling a Unicode project, _TCHAR is wchar_t, not char.

    The %s format specifier expects its corresponding argument to be a char const*; you are passing a wchar_t*, thus the unexpected result.

    You can use _tprintf, which will select the right printf function (printf or wprintf) based on whether the project is being built as ANSI or Unicode. If you want to use printf, you can use the %ls format specifier for wide strings, but then you have to use different format strings depending on whether the project is built as ANSI or Unicode.

    Alternatively, just use Unicode and don’t use _TCHAR and friends at all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my C++ code (I'm using Visual C++ 2010): int absd(int t) {
I want to be able to develop code using Visual Studio 2010. I just
I wrote this simple C code and compiled it using Visual Studio 2010, with
The code below is in C# and I'm using Visual Studio 2010. using System;
I have a asp.net website with c# code behind and using visual studio 2010.
Visual Studio 2010 C# code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using
When I generate code using T4 templates in Visual Studio 2010, I get the
I am writing Python code in Visual Studio 2010 using the excellent Python Tools
I am using an addon called Code Map in Visual Studio 2010 which makes
Using Visual Studio 2010 SP1: #include <vector> //namespace XXX { struct Test { bool

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.