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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:57:21+00:00 2026-06-05T22:57:21+00:00

#include <stdio.h> void wrapperPrint(char* s) { printf(s); return; } int main() { wrapperPrint(Hello world\n);

  • 0
  #include <stdio.h>
  void wrapperPrint(char* s)
  {
      printf(s);
      return;
  }

  int main()
  {

          wrapperPrint("Hello world\n");
          wrapperPrint("This is a string");

      return 0;
  }

If the program prints strings correctly (it does, tested on gcc 4.6.3) , why do we need format specifiers like %d, %s etc. Or in other words, what is the potential problem with this program.

  • 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-05T22:57:23+00:00Added an answer on June 5, 2026 at 10:57 pm

    As-is, there’s no problem at all. If, however, you pass in a string containing a percent-sign, that could cause a problem, because printf would try to treat it as the beginning of a conversion specifier, but 1) the rest of the conversion specifier probably won’t be there, and 2) you won’t have passed a matching argument when you call printf either, so if you do pass a proper conversion specifier, it’ll try to use a nonexistent argument (giving undefined behavior).

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

Sidebar

Related Questions

#include <stdio.h> int main(void){ char x [] = hello world.; printf(%s \n, &x[0]); return
#include <stdio.h> int main(void) { int i,j,k; char st; printf(enter string\n); scanf(%s, st); printf(the
#include<stdio.h> void function(int); int main() { int x; printf(Enter x:); scanf(%d, &x); function(x); return
#include stdio.h int main (void) { char xx[1000] = hello; sprintf (xx, xyzzy plugh
#include <stdio.h> int main(void) { int a[5]={1,2,3,4,5}; int *ptr=(int*)(&a+1); printf(%d %d\n,*(a+1),*(ptr-1)); return 0; }
#include<stdio.h> int main(void) { int i=5; printf(%d, i++ + ++i); return 0; } I
#include<stdio.h> void main() { char *p=nyks; p[2]='n'; printf(%s,p); } This crashes with a SEGMENTATION
#include<stdio.h> int main(void) { int a[3] = {1,2,3}; printf(\n\t %u %u %u \t\n,a,&a,&a+1); return
#include<stdio.h> int main(void) { int i=1,j=-1; if((printf(%d,i))<(printf(%d,j))) printf(%d,i); else printf(%d,j); return 0; } As
#include<stdio.h> void foo(int **arr) { arr[1][1]++; } main() { int arr[20][20]; printf(%d\n,arr[1][1]); foo((int**)arr); printf(%d\n,arr[1][1]);

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.