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 9287057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:34:31+00:00 2026-06-18T19:34:31+00:00

How does a variable arguement function take object to struct/class? For example : CString

  • 0

How does a variable arguement function take object to struct/class?
For example :

CString a_csName;
CString a_csAge(_T("20"));
a_csName.Format(_T("My Age is : %s"),a_csAge);

Here CString::Format is a printf-style variable arguement function which takes this CString object. How is this possible?

  • 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-18T19:34:33+00:00Added an answer on June 18, 2026 at 7:34 pm

    After a bit of researching and debugging through MFC code found the below, hope it helps whoever faces the ever famous static code analyser error “Passing struct ‘CStringT’ to ellipsis” which actually is the source of my doubt as well.

    http://www.gimpel.com/html/bugs/bug437.htm

    Format function being a variadic function, depends on the format specifier present in the first parameter. First parameter is always a char *.

    It parses for the format specifier(%s,%d,%i…) and read the var_arg array based on the index of the format specifier found and does a direct cast to char * if %s or int if %d is specified.

    So if a CString is specified and corresponding format specifier is %s, then a direct cast attempt to char * is made on the CString object.

    CString a_csName;
    CString a_csAge(_T("20"));
    a_csName.Format(_T("My Age is : %s"),a_csAge);
    wcout<<a_csName;
    

    Would print My Age is 20

    CString a_csName;
    CString a_csAge(_T("20"));
    a_csName.Format(_T("My Age is : %d"),a_csAge);
    wcout<<a_csName;
    

    Would print My Age is 052134

    So there is no intelligence behind this. Just a direct cast. Hence we pass a POD or User-Defined Data structure it doesn’t make a difference.

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

Sidebar

Related Questions

Does anyone know how to watch a variable in calling function. For example: C#:
Short version: I'm extending a jQuery object function that is intended to take 0-3
Lets take qsort()'s comparison callback function as an example int (*compar)(const void *, const
What does it mean to take a variable number of arguments by reference? Does
Take a function like printf that accepts a variable number of arguments what I
Does T-SQL allow a variable number of arguments to a stored procedure like params
If i declared a variable as public in a web page, does this variable
I have an array and variable. If the variable does not exist in the
Does anyone know what a variable highlighted in red means? Thanks.
Does an assignment of a real to a variable starting with I convert to

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.