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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:48:31+00:00 2026-06-15T09:48:31+00:00

We have got a text file which contains 10 million integers in a sorted

  • 0

We have got a text file which contains 10 million integers in a sorted order. Need to write a program in C to reverse these numbers and write it to a separate file. Which data structure to use and how to copy such a huge data in memory? And for reversing shall i use fseek or store in some data structure and then reverse?
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-15T09:48:33+00:00Added an answer on June 15, 2026 at 9:48 am

    If you want to run this on a basic desktop system, no special data structure other than a (dynamic) array is needed.

    Just allocate space for e.g. 1,000 numbers initially, startl loading, and double the allocation size when it runs out. This will grow the array like so:

    1,000 -> 2,000 -> 4,000 -> 8,000 -> 16,000 -> 32,000 ->
    

    64,000 -> 128,000 -> 256,000 -> 512,000 -> 1,024,000

    so it will do 10 calls to realloc() which really should be fine.

    Once you have the numbers in an array, just loop over it backwards and print each number to the output file.

    Of course, you can use the fact that you know that there’s a million numbers to your advantage, and set the initial size appropriately.

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

Sidebar

Related Questions

Ok I have created a program which saves text into settings file. So at
I have a text file which contains only lines with a message like: Hello
I have a text file which has over 60MB size. It has got entries
I have a data text file which contains this Map2D, [3, 2] Dot3D, [25,
I have a text file which contains several spelling variants of many words: For
I have a text.txt file which contains following txt. Kontagent Announces Partnership with Global
I have got this text file with latitude and longitude values of different points
I' ve got a problem with Haskell. I have text file looking like this:
On my page in IE8, I have got some text which gets changed through
I have a plain text file that I need to read in using C#,

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.