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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:44:01+00:00 2026-05-25T18:44:01+00:00

I am working on a problem for a class I’m taking in which we

  • 0

I am working on a problem for a class I’m taking in which we need to read in text from a file to a 2d table of strings (called ‘string table[][]’). The text file I’m reading in is formatted as follows:

Ain el Beida # – # – # OEB # Algeria # Africa # F # 42578 # 61997 # 90560 # #

Segbana # – # – # ALI # Benin # Africa # F # -1 # 10219 # -1 # #

Skelmersdale # – # – # LAN # England # Europe # F # 42611 # 42104 # 39279 # #

#

As you can see, each field is separated by a ‘#’, the end of a line is denoted by 2 #’s, and the end of the file with 3 #’s. I’ve been looking at a few different ways of isolating each field so that I can save it to the array, but so far have not found anything that works well for my purpose.

I’ve been banging my head against this for a few hours now and I would really appreciate any advice on how to go about getting this to 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-25T18:44:02+00:00Added an answer on May 25, 2026 at 6:44 pm

    Consider using std::getline, since it allows you to specify a delimiter (in your case, the delimiter is #).

    std::ifstream file("somefile.txt");
    std::string field1;
    std::getline(file, field1, '#'); // Ain el Beida
    

    Note though that each field is actually separated by a space and a #, so you will have leading / trailing whitespace in some cases.

    Since this is for a class, I’ll let you figure out the rest!

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

Sidebar

Related Questions

I am working a problem from the Stanford DB class and have a question.
I'm working on a problem where I need to store serialized hierarchies of Ruby
I’m working on a problem which I know I can solve with C#. I
Currently I am working on a problem which is implemented as a combination of
I do have a problem working with my application. I am using AsyncTask class
I've written this small test class just to illustrate my problem When working with
I'm working on a project using Java RMI. This is the class causing problem:
I am working on this problem a couple of days, my idea is from
Still working on a problem that started from here Calling C++ dll function from
I'm working on a problem which requires me to use the STL linked list

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.