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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:24:03+00:00 2026-05-22T18:24:03+00:00

I am trying to read a set of values from a text file into

  • 0

I am trying to read a set of values from a text file into an array of structures of arrays. The entries are each separated by a ‘\n’, and each entry consists of 3 values, separated by a ‘;’.

The problem is that after correctly reading the first line of file data the program reads the first value from the second line, then seems to fail to read the remaining values. Can you point out the error in my syntax or logic?

The test data appears below.

CS162;Finish Lab 2;9/26/2009
CS201;Take Quiz 1;9/28/2009

After reading in the test data my program’s output is below.

Your tasks are:
Finish Lab 2 for CS162 is due 9/26/2009
CS201
 for  is due

The loops that read the file into the array and outputs the array contents are below. My complete code will be at the end of the question.

for ( ; InputFile.peek() != EOF; ListSize++ )
{
      InputFile.get(TaskList[ListSize].Course, BUFFERSIZE, ';');
      InputFile.ignore(BUFFERSIZE, ';');
      InputFile.get(TaskList[ListSize].Assignment, BUFFERSIZE, ';');
      InputFile.ignore(BUFFERSIZE, ';');
      InputFile.get(TaskList[ListSize].DueDate, BUFFERSIZE, ';');
      InputFile.ignore(BUFFERSIZE, '\n');
}

cout << "Your tasks are:" << endl;
for ( int Iteration = 0; Iteration <= ListSize; Iteration++ )
{
    cout << TaskList[Iteration].Assignment << " for " << TaskList[Iteration].Course << " is due " << TaskList[Iteration].DueDate << endl;
}

Full disclosure, this is for a computer science class. This is why I am not asking for complete code solutions, just help with logic or syntax errors. If I am doing this in completely the wrong way, please point me to documentation to help me. But this does put limitations on my code. The program must use character arrays, not strings.

  • 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-22T18:24:04+00:00Added an answer on May 22, 2026 at 6:24 pm

    Perhaps the last get should be:

    InputFile.get(TaskList[ListSize].DueDate, BUFFERSIZE, '\n');
    

    instead of

    InputFile.get(TaskList[ListSize].DueDate, BUFFERSIZE, ';');
    

    Your last field (due date) does not have a semicolon at the end, only a newline.

    Update: I suggest you also look into using getline instead of get. They have similar functionality, but getline will consume the delimiter also, meaning that you won’t need to use the ignore().

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

Sidebar

Related Questions

This loads a set of values from an XML file and places them into
Im trying to read a column of String values from my DB. Im trying
I'm trying to read xml file from vbs script. Xml is encoded in utf-8
I'm trying to create a Tkinter GUI that saves all entry box values into
After reading from a text file , I am trying to connect to SQLplus
I'm trying to write some Chinese characters to a text file using Set myFSO
I'm trying to import tariff information from an Excel file into a DataTable to
I've been trying to read and set the departmentNumber property for a DirectoryEntry object
Trying to read headers for a csv file with: reader = csv.DictReader(open(PATH_FILE),skipinitialspace=True) headers =
Iam trying to read a binary file to memory and pass the starting address

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.