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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:46:39+00:00 2026-06-09T10:46:39+00:00

i want to take a very long integer(it may contain upto 1000 digits). and

  • 0

i want to take a very long integer(it may contain upto 1000 digits). and i want to store it in an array so that each digit will sit in each place of the array.but if i try to use the code below it takes the whole number in the 0 position untill i press enter. but i can’t press enter. each digit will be scanned separately even though the user will write it as a complete number.

for(count=0;number[count]!='\0';count++){
            scanf("%d",number+count);
        }

what is the way there??

  • 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-09T10:46:40+00:00Added an answer on June 9, 2026 at 10:46 am

    Don’t use scanf. Use fgets to get a line of input as a char*, then you can pull individual digits out of the char* as characters, and convert them to int digits yourself. scanf("%d", ...) will cause problems if the user enters input that can’t be parsed as a digit.

    char *inputLine = malloc(sizeof(char) * (MAX_DIGITS + 1);
    fgets(inputLine, MAX_DIGITS, stdin); // or replace stdin with a FILE *
    

    fgets will consume the entire line of input up to the newline, or stop at the number of characters specified by argument 2.

    If you want to continue reading digit-by-digit, then use getchar() to read individual characters, or fgetc(FILE *) to read individual characters from a file.

    char *inputLine = malloc(sizof(char) * (MAX_DIGITS + 1));
    char ch = getchar();
    int i = 0;
    while ((ch != '\n') && (ch != EOF) && (i < MAX_DIGITS))
    {
        inputLine[i++] = ch;
        ch = getchar();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to take an array and use that array's values to populate an
I want to take a math expression that takes variables and print (assign to
I want to take multiple integer inputs in same line eg :- input -1
I want to find the first matching string in a very very long text.
I've got some long but simple loops in my Delphi program that may loop
I want to parsing Xml from server, but it take long time and finaly
I have a long operation that I want to profile in JProfiler (or other
I want to take a text file with names on each line, such as:
My issue is that sometimes a piece of JavaScript (often Google Analytics) may take
I have one DataSet that contain 2 relate DataTable (master and details). I want

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.