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

  • Home
  • SEARCH
  • 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 9269931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:14:45+00:00 2026-06-18T15:14:45+00:00

I want to implement a function Myprintf() that takes arguments like printf() . Now

  • 0

I want to implement a function Myprintf() that takes arguments like printf().
Now I am doing this by:

sprintf(demoString, "Num=%d String=%s", num, str);
Myprintf(demoString);

I want to replace this function call as:

Myprintf("Num=%d String=%s", num, str);

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-18T15:14:47+00:00Added an answer on June 18, 2026 at 3:14 pm
    #include <stdio.h>
    #include <stdarg.h>
    
    extern int Myprintf(const char *fmt, ...);
    
    int Myprintf(const char *fmt, ...)
    {
        char buffer[4096];
        va_list args;
        va_start(args, fmt);
        int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
        va_end(args);
        ...print the formatted buffer...
        return rc;
    }
    

    It isn’t clear from your question exactly how the output is done; your existing Myprintf() presumably outputs it somewhere, maybe with fprintf(). If that’s the case, you might write instead:

    int Myprintf(const char *fmt, ...)
    {
        va_list args;
        va_start(args, fmt);
        int rc = vfprintf(debug_fp, fmt, args);
        va_end(args);
        return rc;
    }
    

    If you don’t want to use the return value, declare the function as void and don’t bother with the variable rc.

    This is a fairly common pattern for ‘printf() cover functions’.

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

Sidebar

Related Questions

Lets say that I have a function todo() and I want to implement this
In simple words, I want to implement a function like that: let myfunction (scalar
I'm making a Facebook-like chat. I want to implement the function that shows/hides the
Let's say I want to implement a function that is supposed to process an
I'm using R5RS Scheme and I just want to implement a function that returns
In iOS I want to implement the map function for NSArray. This is a
I want to implement filter function that would filter a list based on a
For simplicity, let's say I want to do implement a function which takes two
I want to implement this simple animation in knockout: function scroll(back) { var scrollContainer
everyone! My english is poor and sorry fot that. I want implement a function

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.