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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:31:21+00:00 2026-05-26T05:31:21+00:00

I am having trouble reading data from a file into a list in a

  • 0

I am having trouble reading data from a file into a list in a class. It seems like an extra hexadecimal value is being picked up somewhere.

Data: (what I want output to look like)
enter image description here

Output: (extra 0x4463c4 is randomly included)
enter image description here

Here is a bit of code i think is relevant. Can anyone advise me of errors I may have made?

Where data is read into program from file (main):

struct filmType
{
     char number[6];
     char copy;
     char title[31];
     char rent_id[5];
     char rent_date[9];
     char return_date[9];
};


orderedList <filmType> orderedList;
    filmType newItem;

    //start of struct record
    filmFile.open("films.txt", ios::in);
    filmFile >> numFilm;
    filmFile.get();

    while (!filmFile.eof())
    {
         filmData.copy = filmFile.get();
         readString(filmFile, newItem.title,30);
         readString(filmFile, newItem.rent_id,4);
         readString(filmFile, newItem.rent_date,8);
         readString(filmFile, newItem.return_date,8);
         filmFile.get();

         orderedList.insert (newItem);

         readString(filmFile, filmData.number,5);
    }

orderedlist.insert function:(fills list in class)

void orderedList<elemType>::insert(const elemType& newItem)
{
     int index = length - 1;
     bool found = false;

     if (length == MAX_LIST)
         throw string ("List full - no insertion");

         // index of rear is current value of length

     while (! found && index >= 0)
        if (newItem < list[index])
        {
            list[index + 1] = list [index];  // move item down
            --index;
        }
        else
            found = true;

     list [index + 1] = newItem;  // insert new item
     ++length;
}

Orderedlist.display function: (outputs list to console)

void orderedList<elemType>::display() const
{
    int index;

    if (length == 0)
        throw string ("List empty");

    for (index = 0; index < length; ++ index)
        cout << list[index] << endl;
}

readString:

void readString (fstream & inFile, char * string, int length)
{
    inFile.get (string, length + 1);
}

Any help is appreciated, let me know if anything needs to be clarified or if more code from the program needs to be seen. Thanks!

  • 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-26T05:31:22+00:00Added an answer on May 26, 2026 at 5:31 am

    You’re passing structs objects to cout, which doesn’t know how to display them. The hex values you get are your structs objects addresses.

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

Sidebar

Related Questions

I'm having some trouble reading data from a file into a vector of Orders.
I'm having trouble reading and writing QByteArray data to a file. My goal is
Im having trouble reading from a CSV file final String DELIMITER = ,; Scanner
I'm having trouble reading properties from JSON within NodeJS. Feels like an obvious mistake
I am having trouble reading serial data from ARM LPC2378 microcontroller. Will I have
I am having some trouble reading some data from a serial port I opened
I'm having trouble reading in XML data from an XML resource located in /res/xml/testxml.xml.
I'm having trouble in reading csv file that are having alphanumeric data. below is
I'm having trouble reading a compressed (deflated) data file using C# .NET DeflateStream(..., CompressionMode.Decompress)
I am having trouble reading a csv file, delimited by tabs, in python. I

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.