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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:55:21+00:00 2026-06-09T02:55:21+00:00

How do I printf integers? When I use: int n = GetInt(); printf(%n \n,

  • 0

How do I printf integers? When I use:

int n = GetInt();

printf("%n \n", n);

I get the error that there was an unused variable and I can’t compile it.

  • 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-09T02:55:23+00:00Added an answer on June 9, 2026 at 2:55 am

    As the other answers indicated, you normally print an int with the %d conversion specification, or optionally with the %i conversion specification. You can also use %o, %x or %X (and %u), though technically there’s a signed-to-unsigned conversion implied by doing so.

    Note that %n is a valid conversion specification for printf() et al. However, unlike all the other conversion specifications, the %n conversion specification is an output operation that takes a pointer to an int and it is used to find out how many characters have been written up to that point in the format string. Therefore, you could use:

    int n = GetInt();
    int c;
    
    printf("%d%n\n", n, &c);
    printf("%d characters in number %d\n", c, n);
    

    Note, too, that there is almost never any need for a space before a newline.

    The TR24731-1 (or ISO/IEC 9899:2011 Annex K, Bounds Checking Interfaces) defines printf_s() et al, and explicitly outlaws the %n conversion specification because it often leads to problems precisely because it is an output parameter rather than an input parameter.

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

Sidebar

Related Questions

Why do we at all use integers in C? #include<stdio.h> int main() { char
Hi there I'm trying to input 3 integers from the keyboard and print rows
Well, I completely get the most basic datatypes of C, like short, int, long,
I have homework that should use fork() and wait() system calls: 1) Write two
I'm trying to create a map in Go that is keyed by big integers.
I'm trying to use 64 bit integers in C, but am getting mixed signals
I need to define a main function that reads integers and prints them back
I'm trying to use pythons reduce function on a list containing strings of integers.
I have a lot of code that performs bitwise operations on unsigned integers. I
The following C program: #include <stdio.h> int main(void) { printf("%u %u %u\n",sizeof "",sizeof(""+0),sizeof(char *));

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.