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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:00:30+00:00 2026-06-14T23:00:30+00:00

The problem I have is that I want to disable the user the possibility

  • 0

The problem I have is that I want to disable the user the possibility of putting character instead of number inside my program and optionally printing the message “it is disabled”. It should ask for the value of the same variable. I tried to do this using this:

scanf(" %[0-9]d",&x);

and this:

else
       result = scanf("%*s");

but it still does not work. What should I look for? I’ve searched internet, but I’ve only found solutions for C++ in which cin was used and unfortunately it does not work in C at all.

  • 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-14T23:00:31+00:00Added an answer on June 14, 2026 at 11:00 pm

    You can try something like this:

    char c[SIZE];
    int i;    
    
    // While the string is not a number
    while(fgets(c, SIZE , stdin) && !isAllDigit(c));  
    

    where isAllDigit is:

    int isAllDigit(char *c){
        int i;
        for(i = 0; c[i] != '\0' && c[i] != '\n'; i++) // Verify if each char is a digit
           if(!isdigit(c[i]))         // if it this char is not a digit
               return 0;              // return "false"
    
        return 1; // This means that the string is a number       
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

with my RCP program I have the problem that I want to have more
I have a problem with my site. I want that the shadow stops at
I have the following problem that I want to solve in awk. I have
My problem is that I want to have a tab bar view with its
My problem is simple: I have a long list of elements that I want
I have problem with fancybox. I want to write a function that will run
I have a big problem. I want to extract text from html table that
I have the following problem. I want to check that the item clicked on
I have a UIButton that I disable for a few seconds after the user
well I have that problem, im using a lightbox srcipt and im opening an

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.