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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:04:20+00:00 2026-06-07T16:04:20+00:00

This code doesn’t work but when I put print(7) this works fine: #include<stdio.h> #define

  • 0

This code doesn’t work but when I put print(7) this works fine:

#include<stdio.h>
#define print(i) printf("%"#i"c",ch);

int main(void) 
{
    char ch ='*';
    int N;
    scanf("%d",&N);

    if (N%2 == 0)
    {
            print(N); // print(7);
    }
    else
    {

    }
}

Here is the compilation output

 gcc draw.c -o draw
 draw.c: In function ‘main’:
 draw.c:11: warning: unknown conversion type character ‘N’ in format

How can I get the code to work for a user inserted input. Please help.

  • 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-07T16:04:21+00:00Added an answer on June 7, 2026 at 4:04 pm

    The problem is that the # operator is part of the preprocessor. It doesn’t understand run-time values.

    The printf function recognizes a * syntax that tells it to accept an int argument that specifies a field width, rather than having the width as a constant in the format string.

    For example, this function could replace your macro. Note that I’ve made ch a parameter; I think it’s much clearer that way.

    int print(int n, char ch) {
        return printf("%*c", n, ch);
    }
    

    Personally, I probably wouldn’t bother with either a function or a macro for this; I’d just call printf directly:

    printf("%*c", n, '*');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code works for windows 7 but doesn't work for windows XP (outputs only
This code doesn't work: return this.Context.StockTakeFacts.Select(stf => ((stf.StockTakeId == stocktakeid) && (stf.FactKindId == ((int)kind)))).ToList<IStockTakeFact>();
This code works... $(document).ready(function(){ $('body').css('background','black'); }); but this code doesn't... $(document).ready(function(){ $('thumb_slider').css('background','black'); }); ^^^the
Hey I have this code but it doesn't work because it is expecting a
I tried to use this code but it doesn't work. http://developer.apple.com/library/ios/#samplecode/PageControl/Introduction/Intro.html Ld /Users/waitonza/Library/Developer/Xcode/DerivedData/Dr_Ngoo-aanknxmuodcgjicaigxevljxokeq/Build/Products/Debug-iphonesimulator/Dr Ngoo.app/Dr
This code works only if I reload/refresh page, otherwise it doesn't work, I susspect
i didn't tested this code on iPhone but i'm sure (tested) it doesn't works
I created code for download video from Youtube, but this code doesn't work with
I'm probably misunderstanding JSON, but why this code doesn't work? HTML <html> <head> <title>Test</title>
It looks like this snippet of code doesn't work unless I include the first

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.