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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:16:27+00:00 2026-06-12T18:16:27+00:00

I have searched about this warning and everyone had some mistake in their code,

  • 0

I have searched about this warning and everyone had some mistake in their code, but here is something very unexpected I could not figure out . We do expect strlen(x) to be an integer but what does this warning tell me? How couldn’t strlen be int?

In function ‘fn_product’:
line85:3:warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t’ [-Wformat]

My code in fn_product —

char *fn_product (char x[],char y[]){
  if (strlen(x)==1)    // line85
    printf("\nlength of string--%d\n", strlen(x));
  /*other code*/
}

Shouldn’t strlen(x) be int.Why does it say to be of format size_t?

  • 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-12T18:16:28+00:00Added an answer on June 12, 2026 at 6:16 pm

    Did you check the man page? strlen(3) returns size_t. Use %zu to print it.

    As mentioned in the comments below, clang is sometimes helpful with finding better error messages. clang’s warning for exactly this case is pretty great, in fact:

    example.c:6:14: warning: format specifies type 'unsigned int' but the argument
          has type 'size_t' (aka 'unsigned long') [-Wformat]
        printf("%u\n", strlen("abcde"));
                ~^     ~~~~~~~~~~~~~~~
                %zu
    1 warning generated.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have searched for this but not finding anything about it and if
I have searched about this but can't seem to find exactly how to do
I have searched a lot about this topic and I can't get this code
I have searched about this matter a lot but, I didn't get a proper
I have searched but have not been able to find any information about this.
   I have searched on SO about this question, but I basically haven't found
I have searched on google about this issue and I can't find something that
I searched about this question but can't found any suitable answer: I had been
I have searched a lot about the difference between Website and WebApplication but didn't
I have searched for a CGI and read about it but nothing useful found.

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.