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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:51:47+00:00 2026-05-22T19:51:47+00:00

How can I read a long integer with 12 or 13 digits (like a

  • 0

How can I read a long integer with 12 or 13 digits (like a ISBN number of a book) in C? I want to read the number from a text file with information of books(ISBN/name/writer).

The content of the text file is like this:

0393312836

A Clockwork Orange

Anthony Burgess

0199536759

Middlemarch

Bret Easton Ellis

…

…

…

and I am using this code:

int main(void){

    FILE *f;
    char name[MAX], writer[MAX], line[MAX];
    long isbn;

    f=fopen("path.txt","r");
    if(f == NULL){
        return 0;
        }

    while (fgets(line, 1024, f) != NULL){

        sscanf(line,"%ld", &isbn);
        printf("ISBN: %ld\n",isbn);

        fgets(nome, 1024, f);
        printf("NAME: %s",name);

        fgets(line, 1024, f);
        printf("WRITER: %s",writer);


        }
    fclose(f);

    return 0;

}

he is able to read the names of the books and the writers, but he only reads the numbers if they have 9 digits or less. what do I have to do to make this work?

  • 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-05-22T19:51:47+00:00Added an answer on May 22, 2026 at 7:51 pm

    I think for an ISBN you would be much better using a string. You won’t need to perform arithmetic on the value, you can store leading zeroes and you’ll want a string to store the X that you can get in an ISBN 10 checksum.

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

Sidebar

Related Questions

How you can read a file (text or binary) from a batch file? There
I am trying to read in data from a text file (the time). and
Anyone can read the GoF book to learn what design patterns are and how
I can read settings like this, for example: final String mytest = System.getString(this.getContentResolver(), System.AIRPLANE_MODE_ON);
In Java you can read a file embedded inside a JAR-file by using the
I have text being passed to a function. That text can contain anything, from
Is there any way to get input from a file one number at a
Lately I often have to read Java code like this: LinkedHashMap<String, Integer> totals =
FileStream's read/write method can take only integer value as length. But FileStream object returns
Which are the min/max values I can pass to an Integer/Number? Does Integer use

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.